PROBLEM

First, let’s sort the list. We’ll call the sum of elements `add`

(sorry for the poor naming choice :P). For every index i, let’s define the average as `avg`

. And we’ll also `p`

is the number of people who have at least x dollars. We’ll iterate through every index from the start. If we find an index such that `avg >= x`

, we’ll break the loop and set `p`

to be n - i i.e., the number of people who have at least x dollars. This happens after each iteration. Therefore, we get the maximum value of `p`

.

```
for _ in range(int(input())):
n, x = input().split(' ')
s = list(map(int, input().split(' ')))
s.sort()
add = sum(s)
avg = 0
p = 0
for i in range(0, int(n), 1):
avg += add
avg /= (int(n)-i)
add -= s[i]
if avg >= int(x):
p = (int(n)-i)
break
avg = 0
print(p)
```