Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <iostream>
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5. int main(){
  6.  
  7. int t;
  8. cin >> t;
  9.  
  10. while(t--){
  11.  
  12.   int n,r;
  13.   cin >> n >> r;
  14.   int a[n];
  15.  
  16.   for(int i = 0; i < n; i++ ){
  17.     cin >> a[i];
  18.   }
  19.  
  20.   sort(a,a+n,greater<int>());
  21.  
  22.   int cnt = 0;
  23.  
  24.   for(int i = 0; i <n; i++){
  25.     if(i > 0 && a[i] == a[i-1]);
  26.     else if(a[i] - cnt*r <= 0);
  27.     else{
  28.       cnt++;
  29.     }
  30.   }
  31.  
  32.   cout << cnt << endl;
  33. }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement