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: Accepted)

#include <bits/stdc++.h>
using namespace std;
/*#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }*/

#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<ll, int> pli;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;
typedef std::pair<ll, ll> P;
#define Rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()

template<typename T>
struct SegmentTree {
private:
	int n;
	T E;
	vector<T> node;
	inline void updatef(T& x, T& y) {
		x = y;
		//x += y;
		//x = max(x,y);
		//x = min(x,y);
	}
	inline T queryf(T& x, T& y) {
		return x * y;
		//return x+y;
		//return max(x,y);
		//return min(x,y);
	}

public:
	SegmentTree(int sz, T& E_) :E(E_) {
		n = 1;
		while (n < sz)n <<= 1;
		node.resize(2 * n - 1, E);
	}

	SegmentTree(vector<T>& A, T& E_) :E(E_) {
		int sz = A.size();
		n = 1;
		while (n < sz)n <<= 1;
		node.resize(2 * n - 1, E);
		rep(i, sz)node[i + n - 1] = A[i];
		for (int i = n - 2; i >= 0; --i) {
			node[i] = queryf(node[2 * i + 1], node[2 * i + 2]);
		}
	}
	void update(int k, T x) {
		k += n - 1;
		updatef(node[k], x);
		while (k > 0) {
			k = (k - 1) / 2;
			node[k] = queryf(node[2 * k + 1], node[2 * k + 2]);
		}
	}
	//[a,b)での和を返す
	T get(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0)r = n;
		if (r <= a || b <= l)return E;
		if (a <= l && r <= b)return node[k];
		T xl = get(a, b, 2 * k + 1, l, (l + r) / 2);
		T xr = get(a, b, 2 * k + 2, (l + r) / 2, r);
		return queryf(xl, xr);
	}
};



template<typename T>
struct LazySegmentTree {
private:
	int n;
	vector<T> node, lazy;
	T E0, E1;

	inline void updatef(T& lazy, T& value) {
		lazy += value;
		//lazy = value;
		//lazy = max(lazy, value);
		//lazy = min(lazy, value);
	}
	inline void calculatef(T& node, T& lazy, int len) {
		//node += lazy * len;
		node += lazy;
		//node = lazy ;
	}
	inline T queryf(T& x, T& y) {
		return x + y;
		//return x * y;
		//return max(x, y);
		//return min(x, y);
	}
public:
	LazySegmentTree(int sz, T E0, T E1 = 0) :E0(E0), E1(E1) {
		n = 1;
		while (n < sz)n <<= 1;
		node.resize(2 * n - 1, E0);
		lazy.resize(2 * n - 1, E1);
	}

	LazySegmentTree(vector<T>& v, T nodeE, T lazyE = 0) :E0(nodeE), E1(lazyE) {
		n = 1;
		int sz = v.size();
		while (n < sz)n <<= 1;
		node.resize(2 * n - 1, E0);
		lazy.resize(2 * n - 1, E1);
		rep(i, sz)node[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; --i) {
			node[i] = queryf(node[2 * i + 1], node[2 * i + 2]);
		}
	}

	void eval(int k, int l, int r) {
		if (lazy[k] == E1)return;
		calculatef(node[k], lazy[k], r - l);
		if (r - l > 1) {
			updatef(lazy[2 * k + 1], lazy[k]);
			updatef(lazy[2 * k + 2], lazy[k]);
		}
		lazy[k] = E1;
	}
	//[a,b)にxを加算
	void update(int a, int b, T x, int k = 0, int l = 0, int r = -1) {
		if (r < 0)r = n;
		eval(k, l, r);
		if (r <= a || b <= l)return;
		if (a <= l && r <= b) {
			updatef(lazy[k], x);
			eval(k, l, r);
		} else {
			update(a, b, x, 2 * k + 1, l, (l + r) / 2);
			update(a, b, x, 2 * k + 2, (l + r) / 2, r);
			node[k] = queryf(node[2 * k + 1], node[2 * k + 2]);
		}
	}
	//[a,b)での和を返す
	T query(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0)r = n;
		eval(k, l, r);
		if (r <= a || b <= l)return E0;
		if (a <= l && r <= b)return node[k];
		T xl = query(a, b, 2 * k + 1, l, (l + r) / 2);
		T xr = query(a, b, 2 * k + 2, (l + r) / 2, r);
		return queryf(xl, xr);
	}
};


int main() {
	ll n, d, a;
	cin >> n >> d >> a;
	LazySegmentTree<ll> sg(n, 0, 0);
	vector<ll> x(n), h(n);
	vector<P> p(n);
	Rep(i, n) {
		cin >> x[i] >> h[i];
		p[i].first = x[i];
		p[i].second = h[i];
	}
	sort(all(p));
	ll res = 0;
	Rep(i, n) {
		x[i] = p[i].first;
		h[i] = p[i].second;
	}
	Rep(i, n) {
		sg.update(i, i + 1, h[i]);
	}
	Rep(i, n) {
		if (sg.query(i, i + 1) > 0) {
			ll t = p[i].first + 2 * d + 1;
			auto itr = lower_bound(all(x), t) - x.begin() - 1;
			ll tmp = sg.query(i, i + 1);
			tmp = (tmp + a - 1) / a;
			res += tmp;
			sg.update(i, itr + 1, -tmp * a);

		}
		

	}
	cout << res << endl;
	/*for (int i = 0; i < q; i++) {
		int c, s, t, x;
		cin >> c;
		if (c) {
			cin >> x;
			cout << ss.query(x - 1, x) << endl;
		} else {
			cin >> s >> t >> x;
			ss.add(s - 1, t, x);
		}
	}*/
	return 0;
}