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++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0L;i--)
#define positiverep(i,n) for(int64_t i=1;i <= (int64_t)(n);i++)
using namespace std;


//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/
bool cmp1(const pair<int64_t,int64_t> &a,const pair<int64_t,int64_t> &b){
  return a.first < b.first;
}
bool cmp2(const pair<int64_t,int64_t> &a,const pair<int64_t,int64_t> &b){
  return a.second < b.second;
}

int main(){
  int64_t n,d,a;
  cin >> n >> d >> a;
  vector<pair<int64_t,int64_t>> xh(n);
  rep(i,n){
    int64_t hoge1,hoge2;
    cin >> hoge1 >> hoge2;
    xh.at(i) = make_pair(hoge1,(hoge2+a-1)/a);
  }
  //sort(xh.begin(),xh.end(),cmp2);
  sort(xh.begin(),xh.end());
  vector<int64_t> dmgcnt(n);
  int64_t damage = 0;
  int64_t damagetotal = 0;
  rep(i,n){
    //printf("%ld 's HP = %ld\n",i,xh.at(i).second - damage);
    if(damage < xh.at(i).second){
      auto itr = upper_bound(xh.begin(),xh.end(), make_pair(xh.at(i).first + 2*d,xh.at(i).second),cmp1);
      int iii = distance(xh.begin(),itr);
      dmgcnt.at(i) +=  xh.at(i).second - damage;
      //cout << iii << endl;
      if(iii <= n-1){
        dmgcnt.at(iii) -= xh.at(i).second - damage;
      }
      damagetotal += xh.at(i).second - damage;
      
      damage += xh.at(i).second - damage;
      if(i+1 < n) damage += dmgcnt.at(i+1);
      //cout << "###" << damage << endl;
    }
    //cout << "///" << damagetotal << endl;
  }
  /*damage += dmgcnt.at(n-2);
  if(damage < xh.at(n-1).second){
    damagetotal += xh.at(n-1).second - damage;
    damagetotal += xh.at(n-1).second - damage;
  }*/
    
  cout << damagetotal << endl;
    
    
    
    
                           

}