1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 const int N=1e5+10; 5 ll a[N]; 6 int main(){ 7 int t ; 8 cin>>t; 9 while(t--){ 10 int n; 11 ll k; 12 scanf("%d%lld",&n,&k); 13 for(int i=1;i<=n;i++) scanf("%lld",&a[i]); 14 sort(a+1,a+1+n); 15 int sum=0; 16 for(int i=n;i>=2;i--){ 17 if(a[i]-a[i-1]>k) break; 18 sum++; 19 } 20 cout<<sum+1<<endl; 21 }
时间: 2024-10-10 00:00:17