【題目敘述】https://atcoder.jp/contests/abc153/tasks/abc153_f
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
int n, d, a, x, h;
long long s, ans;
vector <pair<int, int> > v;
queue <pair<int, long long> > q;
int main(){
cin >> n >> d >> a;
for (int i = 0; i < n; i++){
cin >> x >> h;
v.push_back({x, (h-1)/a+1});
}
sort(v.begin(), v.end());
for (int i = 0; i < n; i++){
while (!q.empty() && q.front().second < v[i].first){
s -= q.front().first;
q.pop();
}
if (s < v[i].second){
q.push({v[i].second-s, v[i].first+d*2});
ans += v[i].second - s;
s = v[i].second;
}
}
cout << ans << "\n";
}