Advertisement
Farjana_akter

Untitled

Feb 9th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. long long int t,n,k,i,j,count=1,a[1000],b,c,d;
  7. cin>>t;
  8. for(i=1;i<=t;i++)
  9. {
  10. cin>>n>>k;
  11. count=1;
  12. for(j=0;j<n;j++)
  13. cin>>a[j];
  14. sort(a,a+n);
  15. for(j=1;j<n;j++)
  16. {
  17. b=a[j]-a[j-1];
  18. if(b>k)
  19. count++;
  20. }
  21. cout<<"Case #"<<i<<": "<<count<<endl;
  22. }
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement