#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, m = 0, j, i, d, k = 0, n;
  cin >> t;
  for (i = 0; i < t; i++) {
    m = 0;
    k = 0;
    cin >> n >> d;
    long long int a[n];
    for (j = 0; j < n; j++) {
      cin >> a[j];
    }
    sort(a, a + n);
    for (j = n - 1; j >= 0; j--) {
      m = m + a[j];
      if (m >= (n - j) * d)
        k++;
      else
        break;
    }
    cout << k << endl;
  }
}
