#include<bits/stdc++.h> #define ff first #define ss second #define pb push_back #define mp make_pair #define ll long long #define all(a) a.begin(),a.end() #define endl '\n' #define int ll using namespace std; const int N = 3e5 + 3; int n, k; int a[N]; bool used[N]; set<pair<int, int> > st; int find_pair(int i) { if(i == 0) return 0; if(!used[i]) { st.erase(mp(a[i], i)); } auto it = st.lower_bound(mp(k - a[i], 0)); if(it == st.begin()) { if(!used[i]) { st.insert(mp(a[i], i)); } return 0; } it--; int res = it->ss; if(!used[i]) { st.insert(mp(a[i], i)); } return res; } void solve() { cin >> n >> k; for(int i = 1; i <= n; ++i) { used[i] = false; } st.clear(); for(int i = 1; i <= n; ++i) { cin >> a[i]; } sort(a + 1, a + n + 1); for(int i = 1; i <= n; ++i) { st.insert(mp(a[i], i)); } int prI = n; int mxI = n; int ans = 0; for(int i = n; i >= 1; i--) { if(used[i]) continue; st.erase(mp(a[i], i)); used[i] = true; ans++; while(prI > 0 && (used[prI] || !find_pair(prI))) { prI--; } int pr = find_pair(prI); if(pr) { used[prI] = true; st.erase(mp(a[prI], prI)); used[pr] = true; st.erase(mp(a[pr], pr)); } else { auto it = st.lower_bound(mp(k, 0)); if(it != st.begin()) { it--; used[it->ss] = true; st.erase(it); } } } cout << ans - 1 << endl; } main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int t; cin >> t; while(t--) { solve(); } } /* 1 8 37 2 13 13 11 12 19 16 18 1 6 10 2 6 8 2 6 8 1 3 10 2 6 8 1 4 4 2 3 4 4 5 8 25 4 5 18 3 17 17 18 14 7 21 20 14 1 4 20 8 4 8 1 20 5 9 4 14 12 2 20 8 37 2 13 13 11 12 19 16 18 4 38 15 3 14 7 1 7 21 20 14 1 4 20 8 4 1 8 25 4 5 18 3 17 17 18 14 5 8 25 4 5 18 3 17 17 18 14 7 21 20 14 1 4 20 8 4 8 1 20 5 9 4 14 12 2 20 8 37 2 13 13 11 12 19 16 18 4 38 15 3 14 7 1 8 1 20 5 9 4 14 12 2 20 */