标签:ons i++ for include end main scan can sort
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 }
标签:ons i++ for include end main scan can sort
原文地址:http://www.cnblogs.com/hhxj/p/7309135.html