Problem:
Score : 600 points

Problem Statement

Silver Fox is fighting with N monsters.

The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the health of H_i.

Silver Fox can use bombs to attack the monsters.
Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A.
There is no way other than bombs to decrease the monster's health.

Silver Fox wins when all the monsters' healths become 0 or below.

Find the minimum number of bombs needed to win.

Constraints

1 \leq N \leq 2 \times 10^5

0 \leq D \leq 10^9

1 \leq A \leq 10^9

0 \leq X_i \leq 10^9

1 \leq H_i \leq 10^9

X_i are distinct.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N D A
X_1 H_1
:
X_N H_N

Output

Print the minimum number of bombs needed to win.

Sample Input 1

3 3 2
1 2
5 4
9 2

Sample Output 1

2

First, let us use a bomb at the coordinate 4 to decrease the first and second monsters' health by 2.

Then, use a bomb at the coordinate 6 to decrease the second and third monsters' health by 2.

Now, all the monsters' healths are 0.
We cannot make all the monsters' health drop to 0 or below with just one bomb.

Sample Input 2

9 4 1
1 5
2 4
3 3
4 2
5 1
6 2
7 3
8 4
9 5

Sample Output 2

5

We should use five bombs at the coordinate 5.

Sample Input 3

3 0 1
300000000 1000000000
100000000 1000000000
200000000 1000000000

Sample Output 3

3000000000

Watch out for overflow.

Solution in C++ (GCC 9.2.1) (judge verdict: Accepted)

#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
#define MOD 1000000007
#define mod9 1000000009
#define fast ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define mp make_pair
#define pb push_back
#define ct ll t;cin>>t;while(t--)
#define bi begin()
#define ei end()
#define fi first 
#define se second  
#define foe(i,a,b) for(ll i=a;i<b;i++)
#define sz(s) s.size() 
#define mem(a,s) memset(a,s,sizeof(a)) 
#define all(v) v.bi,v.ei
#define MAX             8000000000000000064LL
#define MIN            -8000000000000000064LL  
// ll MOD; 
ll add(ll a, ll b){return (a%MOD + b%MOD + ((MAX)/MOD)*MOD)%MOD;}
ll sub(ll a, ll b){return (a%MOD - b%MOD + ((MAX)/MOD)*MOD)%MOD;}
ll mul(ll a, ll b){return ((a%MOD)*(b%MOD) + ((MAX)/MOD)*MOD)%MOD;}
bool isPrime(ll n) 
{ 
    // Corner case 
    if (n <= 1) 
        return false; 
    
    // Check from 2 to n-1 
    for (ll i = 2; i*i <= n; i++) 
        if (n % i == 0) 
            return false; 
    
    return true; 
}
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = mul(res,a);
        a = mul(a,a);
        b >>= 1;
    }
    return res%MOD;
}

bool compare(const pair<ll,ll>&a,const pair<ll,ll>&b)
{
    return (a.se>b.se);
}
ll lcm(ll a,ll b)
{
    return(a*b)/__gcd(a,b);
}
vector<ll>s;
// set<ll>s1;
bool prime[100009]={false};
    // set<ll>s1;
    void Sieve() 
    {  
        ll n=100009;
        prime[0]=prime[1]=true;
        // s[0]=0;
        // s[1]=1;
        // s.pb(1);
        // t.insert(1);
        for (int p=2; p*p<=n; p++) 
        { 
        
        if(prime[p]==false)
        {
            //    s.pb(p);
            for(ll j=p*p;j<=n;j+=p)
            {
                prime[j]=true;
            }    
        }
        } 
        for(ll i=2;i<n;i++)
        {
            if(!prime[i])
            {
                s.pb(i);
                // s1.insert(i);
            }
        }
} 
//     ll eea(ll a, ll b, ll & x, ll & y) {
//     if (a == 0) {
//         x = 0;
//         y = 1;
//         return b;
//     }
//     ll x1, y1;
//     ll d=eea(b % a, a, x1, y1);
//     x = y1 - (b / a) * x1;
//     y = x1;
//     return d;
// }
// bool find_any_solution(ll a, ll b, ll c, ll &x0, ll &y0, ll &g) {
//     g = eea(abs(a), abs(b), x0, y0);
//     if (c % g) {
//         return false;
//     }

//     x0 *= c / g;
//     y0 *= c / g;
//     if (a < 0) x0 = -x0;
//     if (b < 0) y0 = -y0;
//     return true;
// }
// ll modinverse(ll a,ll m)
// {
//     ll x, y;
//     eea(a, m, x, y);
//     if (__gcd(a,m) != 1) {
//     return -1;
//     }
// else {
//     x = (x % m + m) % m;
//     cout << x << endl;
//     return x;
// }
// }

ll fact[1000007]={0};
ll expo(ll x, ll y) {ll res=1;x=x%MOD;while(y>0){if(y&1)res=(1ll*res*x)%MOD;
y=y>>1;x=(1ll*x*x)%MOD;} return res;}
void facto() {fact[0]=1;fact[1]=1;for(ll i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%MOD;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expo(fact[r],MOD-2)))%MOD; res=(res*(expo(fact[n-r],MOD-2)))%MOD; return res;}
ll npr(ll n,ll r) {facto(); ll res=1; res=fact[n]; res=(res*(expo(fact[n-r],MOD-2)))%MOD; return res; }
int const N=2e5+9;
ll const INF = 2e18+5;
void solve()
{
    ll n,d,a;
    cin>>n>>d>>a;
    vector<pair<ll,ll>>v(n);
    ll dp[N]={0};
    foe(i,0,n)
    {
        cin>>v[i].fi>>v[i].se;
    }    
    sort(all(v));
    ll ans=0;
    foe(i,0,n)
    {
        if(v[i].se>dp[i])
        {
            ll t=v[i].se-dp[i];
            t=(t+a-1)/a;
            dp[i]+=t*a;
            ans+=t;
            ll k=(ll)(upper_bound(all(v),mp(v[i].fi+2*d,(ll)1e18))-v.begin());    
            dp[k]-=t*a;
        }
        dp[i+1]+=dp[i];
    }
    cout<<ans<<"\n";
}   
int main()
{
    fast
    // Sieve();
//    ct
    { 
        solve();
    }
}