#include <bits/stdc++.h> #define int long long #define MULTITEST true /* Checking C/01.in... 1,10c1,2 < 3 4 < 5 2 < 4 2 < 3 4 < 4 < 3 2 < 1 4 < 2 4 < 2 4 < 3 --- > 2 > 2 12,18c4,5 < 3 4 < 5 2 < 4 2 < 3 4 < 4 < 1 2 < 3 --- > 2 > 1*/ using namespace std; vector<int>a; int nn,k; int check(int x){ int r = nn - x; int ans = 0; r--; int l = 0; while(r>=l){ if(a[r]+a[l]<k&&l!=r){ if(l+1!=r) ans++; r--; l++; continue; } if(a[r]>=k){ return false; } if(l!=r) ans++; r--; } //cout<<x<<' '<<ans<<endl; return ans<=x; } int bin(int l,int r){ if(l==r){ return l; } if(l+1==r){ if(check(l)){ return l; } return r; } int m = (l+r)/2; if(check(m)){ return bin(l,m); } else{ return bin(m,r); } } void solve () { int n; cin>>n>>k; nn=n; a.clear(); a.resize(n); for(int i=0;i<n;i++){ cin>>a[i]; } sort(a.begin(),a.end()); nn--; cout<<bin(0, nn)<<endl; } signed main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.precision(30); int T = 1; if (MULTITEST) cin >> T; for (int t = 0; t < T; t ++) solve(); }