using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("3 3 2");
WillReturn.Add("1 2");
WillReturn.Add("5 4");
WillReturn.Add("9 2");
//2
}
else if (InputPattern == "Input2") {
WillReturn.Add("9 4 1");
WillReturn.Add("1 5");
WillReturn.Add("2 4");
WillReturn.Add("3 3");
WillReturn.Add("4 2");
WillReturn.Add("5 1");
WillReturn.Add("6 2");
WillReturn.Add("7 3");
WillReturn.Add("8 4");
WillReturn.Add("9 5");
//5
}
else if (InputPattern == "Input3") {
WillReturn.Add("3 0 1");
WillReturn.Add("300000000 1000000000");
WillReturn.Add("100000000 1000000000");
WillReturn.Add("200000000 1000000000");
//3000000000
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
struct XHInfoDef
{
internal long X;
internal long H;
}
static void Main()
{
List<string> InputList = GetInputList();
long[] wkArr = { };
Action<string> SplitAct = pStr =>
wkArr = pStr.Split(' ').Select(pX => long.Parse(pX)).ToArray();
SplitAct(InputList[0]);
long D = wkArr[1];
long A = wkArr[2];
var XHInfoList = new List<XHInfoDef>();
foreach (string EachStr in InputList.Skip(1)) {
SplitAct(EachStr);
XHInfoDef WillAdd;
WillAdd.X = wkArr[0];
WillAdd.H = wkArr[1];
XHInfoList.Add(WillAdd);
}
XHInfoList = XHInfoList.OrderBy(pX => pX.X).ToList();
// 座圧後の値[座圧前の値]なDict
Dictionary<long, long> ZaatuDict = DeriveZaatuDict(XHInfoList.Select(pX => pX.X));
var InsLazySegmentTree = new LazySegmentTree(ZaatuDict.Count);
foreach (XHInfoDef EachXHInfo in XHInfoList) {
long ZaatuVal = ZaatuDict[EachXHInfo.X];
InsLazySegmentTree.RangeAdd(ZaatuVal, ZaatuVal, EachXHInfo.H, 0);
}
long[] KeysArr = ZaatuDict.Keys.ToArray();
long Answer = 0;
foreach (XHInfoDef EachXHInfo in XHInfoList) {
long ZaatuValSta = ZaatuDict[EachXHInfo.X];
long CurrVal = InsLazySegmentTree.Query(ZaatuValSta, ZaatuValSta, 0);
if (CurrVal <= 0) continue;
long Cnt = CurrVal / A;
if (CurrVal % A > 0) Cnt++;
long RangeEnd = EachXHInfo.X + 2 * D;
int LowerOrEqual_Max = ExecNibunhou_LowerOrEqual_Max(RangeEnd, KeysArr);
long ZaatuValEnd = ZaatuDict[KeysArr[LowerOrEqual_Max]];
InsLazySegmentTree.RangeAdd(ZaatuValSta, ZaatuValEnd, -(Cnt * A), 0);
Answer += Cnt;
}
Console.WriteLine(Answer);
}
//////////////////////////////////////////////////////////////////////////
// 列挙を引数として、座標圧縮し、座圧後の値[座圧前の値]なDictを返す
//////////////////////////////////////////////////////////////////////////
static Dictionary<long, long> DeriveZaatuDict(IEnumerable<long> pEnum)
{
var ZaatuDict = new Dictionary<long, long>();
var ValSet = new HashSet<long>(pEnum);
long No = 0;
foreach (long EachVal in ValSet.OrderBy(pX => pX)) {
ZaatuDict[EachVal] = No;
No++;
}
return ZaatuDict;
}
// 二分法で、Val以下で最大の値を持つ、添字を返す
static int ExecNibunhou_LowerOrEqual_Max(long pVal, long[] pArr)
{
// 最後の要素がVal以下の特殊ケース
if (pVal >= pArr.Last()) {
return pArr.GetUpperBound(0);
}
// 最初の要素がVal超えの特殊ケース
if (pVal < pArr[0]) {
return -1;
}
int L = 0;
int R = pArr.GetUpperBound(0);
while (L + 1 < R) {
int Mid = (L + R) / 2;
if (pArr[Mid] <= pVal) {
L = Mid;
}
else {
R = Mid;
}
}
return L;
}
}
#region LazySegmentTree
// LazySegmentTreeクラス (RSQ and RAQ)
internal class LazySegmentTree
{
private long[] mTreeNodeArr;
private long UB; // 木のノードの配列のUB
private long mLeafCnt; // 葉ノードの数
private long[] mLazyArr; // 遅延配列
// ノードの添字を引数とし、範囲の開始添字と終了添字を持つ配列
private struct RangeInfoDef
{
internal long StaInd;
internal long EndInd;
}
private RangeInfoDef[] mRangeInfo;
// コンストラクタ
internal LazySegmentTree(long pLeafCnt)
{
// 簡単のため、葉ノード数を2のべき乗に
long ArrLength = 0;
for (long I = 1; I < long.MaxValue; I *= 2) {
ArrLength += I;
mLeafCnt = I;
if (pLeafCnt < mLeafCnt) break;
}
// すべての値を0に
UB = ArrLength - 1;
mTreeNodeArr = new long[UB + 1];
for (int I = 0; I <= UB; I++) {
mTreeNodeArr[I] = 0;
}
// 遅延配列を初期化
mLazyArr = new long[UB + 1];
// ノードの添字を引数とし、範囲の開始添字と終了添字を持つ配列の作成
mRangeInfo = new RangeInfoDef[UB + 1];
for (long I = 0; I <= UB; I++) {
if (I == 0) {
RangeInfoDef WillSet1;
WillSet1.StaInd = 0;
WillSet1.EndInd = mLeafCnt - 1;
mRangeInfo[I] = WillSet1;
continue;
}
long ParentNode = DeriveParentNode(I);
RangeInfoDef ParentRangeInfo = mRangeInfo[ParentNode];
RangeInfoDef WillSet2;
long Mid = (ParentRangeInfo.StaInd + ParentRangeInfo.EndInd) / 2;
if (I % 2 == 1) { // 奇数ノードの場合
WillSet2.StaInd = ParentRangeInfo.StaInd;
WillSet2.EndInd = Mid;
}
else { // 偶数ノードの場合
WillSet2.StaInd = Mid + 1;
WillSet2.EndInd = ParentRangeInfo.EndInd;
}
mRangeInfo[I] = WillSet2;
}
}
// 親ノードの添字を取得
private long DeriveParentNode(long pTarget)
{
return (pTarget - 1) / 2;
}
// 子ノードの添字(小さいほう)を取得
private long DeriveChildNode(long pTarget)
{
return pTarget * 2 + 1;
}
// 開始添字と終了添字とカレントノードを引数として、区間加算を行う
internal void RangeAdd(long pSearchStaInd, long pSearchEndInd, long pAddVal, long pCurrNode)
{
// カレントノードの遅延評価を行う
LazyEval(pCurrNode);
long CurrNodeStaInd = mRangeInfo[pCurrNode].StaInd;
long CurrNodeEndInd = mRangeInfo[pCurrNode].EndInd;
// OverLapしてなければ、何もしない
if (CurrNodeEndInd < pSearchStaInd || pSearchEndInd < CurrNodeStaInd)
return;
// 完全に含んでいれば、遅延配列に値を入れた後に評価
if (pSearchStaInd <= CurrNodeStaInd && CurrNodeEndInd <= pSearchEndInd) {
mLazyArr[pCurrNode] += pAddVal * (CurrNodeEndInd - CurrNodeStaInd + 1);
LazyEval(pCurrNode);
return;
}
// そうでなければ、2つの区間に再帰呼出し
long ChildNode1 = DeriveChildNode(pCurrNode);
long ChildNode2 = ChildNode1 + 1;
RangeAdd(pSearchStaInd, pSearchEndInd, pAddVal, ChildNode1);
RangeAdd(pSearchStaInd, pSearchEndInd, pAddVal, ChildNode2);
mTreeNodeArr[pCurrNode] = mTreeNodeArr[ChildNode1] + mTreeNodeArr[ChildNode2];
}
// 開始添字と終了添字とカレントノードを引数として、Sumを返す
internal long Query(long pSearchStaInd, long pSearchEndInd, long pCurrNode)
{
// 該当ノードを遅延評価する
LazyEval(pCurrNode);
long CurrNodeStaInd = mRangeInfo[pCurrNode].StaInd;
long CurrNodeEndInd = mRangeInfo[pCurrNode].EndInd;
// OverLapしてなければ、0
if (CurrNodeEndInd < pSearchStaInd || pSearchEndInd < CurrNodeStaInd)
return 0;
// 完全に含んでいれば、このノードの値
if (pSearchStaInd <= CurrNodeStaInd && CurrNodeEndInd <= pSearchEndInd)
return mTreeNodeArr[pCurrNode];
// そうでなければ、2つの子のSum
long ChildNode1 = DeriveChildNode(pCurrNode);
long ChildNode2 = ChildNode1 + 1;
long ChildVal1 = Query(pSearchStaInd, pSearchEndInd, ChildNode1);
long ChildVal2 = Query(pSearchStaInd, pSearchEndInd, ChildNode2);
return ChildVal1 + ChildVal2;
}
// カレントノードを引数として、遅延評価を行う
void LazyEval(long pCurrNode)
{
// 遅延配列が0なら何もしない
if (mLazyArr[pCurrNode] == 0) return;
// 遅延配列の値を設定する
mTreeNodeArr[pCurrNode] += mLazyArr[pCurrNode];
long ChildNode1 = DeriveChildNode(pCurrNode);
long ChildNode2 = ChildNode1 + 1;
if (ChildNode1 <= UB) mLazyArr[ChildNode1] += mLazyArr[pCurrNode] / 2;
if (ChildNode2 <= UB) mLazyArr[ChildNode2] += mLazyArr[pCurrNode] / 2;
// 伝播が終わったので、自ノードの遅延配列を空にする
mLazyArr[pCurrNode] = 0;
}
internal void DebugPrint()
{
for (int I = 0; I <= UB; I++) {
if (mLazyArr[I] > 0) {
Console.WriteLine("mTreeNodeArr[{0}] = {1} , mLazyArr[{0}] = {2}",
I, mTreeNodeArr[I], mLazyArr[I]);
}
else {
Console.WriteLine("mTreeNodeArr[{0}] = {1}", I, mTreeNodeArr[I]);
}
}
}
}
#endregion