COFO::1238B Kill ‘Em all

Problem

Point

Design

Complexity

Code

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define r_rep(i, a, b) for(int i=(a); i >(b); i--)
typedef long long ll;
using namespace std;

int n, r;
vector<int> a;
void solve(){
    cin >> n >> r;
    a.clear(); a.resize(n);
    rep(i, 0, n) cin >> a[i];
    sort(all(a));
    a.erase(unique(all(a)), a.end());
    
    int cnt = 0;
    n = sz(a);
    r_rep(i, n-1, -1){
        int v = a[i] - cnt * r;
        if(v <= 0) break;
        cnt++;
    }
    cout << cnt << '\n';
}
int main(){
    cin.tie(0);
    int tc; cin >> tc;
    while(tc--)
        solve();
    return 0;
}