mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
33 lines
607 B
C++
33 lines
607 B
C++
#include <vector>
|
|
#include <cstdio>
|
|
#include <algorithm>
|
|
#include <functional>
|
|
using namespace std;
|
|
|
|
int main()
|
|
{
|
|
int t;
|
|
scanf("%d",&t);
|
|
while(t--)
|
|
{
|
|
int n,k;
|
|
scanf("%d %d",&n,&k);
|
|
vector<int> vec;
|
|
int temp;
|
|
for(int i=0;i<n;i++)
|
|
{
|
|
scanf("%d",&temp);
|
|
vec.push_back(temp);
|
|
}
|
|
sort(vec.begin(),vec.end(),greater<int>());
|
|
int cnt=1;
|
|
for(int i=0;i<n-1;i++)
|
|
{
|
|
if(vec[i]-vec[i+1]<=k) ++cnt;
|
|
else break;
|
|
}
|
|
printf("%d\n",cnt);
|
|
}
|
|
|
|
return 0;
|
|
} |