CF BUDDY
← Problems·

1334B · Middle Class

1100 · greedy, sortings

Problem: Many years ago Berland was a small country where only nn people lived. Each person had some savings: the ii-th one had aia_i burles.

The government considered a person as wealthy if he had at least xx burles. To increase the number of wealthy people Berland decided to carry out several reforms. Each reform looked like that:

  • the government chooses some subset of people (maybe all of them);
  • the government takes all savings from the chosen people and redistributes the savings among the chosen people equally.

For example, consider the savings as list [5,1,2,1][5, 1, 2, 1]: if the government chose the 11-st and the 33-rd persons then it, at first, will take all 5+2=75 + 2 = 7 burles and after that will return 3.53.5 burles to the chosen people. As a result, the savings will become [3.5,1,3.5,1][3.5, 1, 3.5, 1].

A lot of data was lost from that time, so we don't know how many reforms were implemented and to whom. All we can do is ask you to calculate the maximum possible number of wealthy people after several (maybe zero) reforms.

Input Format: The first line contains single integer TT (1T10001 \le T \le 1000) — the number of test cases.

Next 2T2T lines contain the test cases — two lines per test case. The first line contains two integers nn and xx (1n1051 \le n \le 10^5, 1x1091 \le x \le 10^9) — the number of people and the minimum amount of money to be considered as wealthy.

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (1ai1091 \le a_i \le 10^9) — the initial savings of each person.

It's guaranteed that the total sum of nn doesn't exceed 10510^5.

Output Format: Print TT integers — one per test case. For each test case print the maximum possible number of wealthy people after several (maybe zero) reforms.

Note: The first test case is described in the statement.

In the second test case, the government, for example, could carry out two reforms: [11,9,11,9][10,10,11,9][10,10,10,10][\underline{11}, \underline{9}, 11, 9] \rightarrow [10, 10, \underline{11}, \underline{9}] \rightarrow [10, 10, 10, 10].

In the third test case, the government couldn't make even one person wealthy.

In the fourth test case, the government could choose all people to carry out a reform: [9,4,9][713,713,713][\underline{9}, \underline{4}, \underline{9}] \rightarrow [7\frac{1}{3}, 7\frac{1}{3}, 7\frac{1}{3}].

Sample Cases

Case 1

Input

4
4 3
5 1 2 1
4 10
11 9 11 9
2 5
4 3
3 7
9 4 9

Output

2
4
0
3

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback