Advertisement
erfanul007

LA 6906

Dec 7th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int t,i=0;
  7. cin>>t;
  8. while(t--){
  9. i++;
  10. int n,k,x,j,cnt=1;
  11. cin>>n>>k;
  12. vector<int>vt;
  13. for(j=0;j<n;j++){
  14. scanf("%d",&x);
  15. vt.push_back(x);
  16. }
  17. sort(vt.begin(),vt.end());
  18. for(j=1;j<n;j++){
  19. if(vt[j]-vt[j-1]>k)
  20. cnt++;
  21. }
  22. cout<<"Case #"<<i<<": "<<cnt<<endl;
  23. vt.clear();
  24. }
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement