fork(2) download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6. int t; cin >> t;
  7. for(int i = 1; i <= t; i++){
  8. int n, k; cin >> n >> k;
  9. int a[n];
  10. for(int &x : a) cin >> x;
  11. sort(a, a + n);
  12. int cnt = 1;
  13. for(int i = 1 ; i < n; i++){
  14. if(a[i] - a[i-1] <= k ){
  15. continue;
  16. }
  17. else{
  18. ++cnt;
  19. }
  20. }
  21. cout <<"Case #" << i << ": ";
  22. cout << cnt << endl;
  23. }
  24. }
  25.  
Success #stdin #stdout 0.01s 5504KB
stdin
Standard input is empty
stdout
Standard output is empty