题目链接:Lovers
/*
* [链接]:https://nanti.jisuanke.com/t/A1608
*
* [题意]:给定两个长度为n的数组a.b,问存在最多多少对(i,j)使得,a[i]+a[j]>=k。
*
* [分析]:贪心,一个从大往小的找,一个从小往大的找。
*
* [tricks]:
*
*
* [时间复杂度]:t*n*log(n)
*
*
*
*
*
* */
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void scan() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
const int maxn = 1e6 + 7;
ll a[maxn], b[maxn];
int main() {
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
scan();
int t;
cin >> t;
while (t--) {
int n;
ll k;
cin >> n >> k;
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < n; i++) cin >> b[i];
sort(a, a + n);
sort(b, b + n, greater<ll>());
int j = 0;
ll ans = 0;
for (int i = 0; i < n && j < n; i++) {
if (a[i] + b[j] >= k) ans++, j++;
}
cout << ans << endl;
}
return 0;
}