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# (Mono 4.6.2.0) (judge verdict: Time Limit Exceeded)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            int iD = int.Parse(sS[1]);
            int iA = int.Parse(sS[2]);
            List<ClsMns> lstMgcP = new List<ClsMns>();
            for (int i = 0; i < iN; i++)
            {
                sS = System.Console.ReadLine().Trim().Split(' ');
                ClsMns oneUsr = new ClsMns();
                //oneUsr.iN = i;
                oneUsr.iX = int.Parse(sS[0]);
                oneUsr.iH = int.Parse(sS[1]);
                lstMgcP.Add(oneUsr);
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            lstMgcP.Sort(delegate (ClsMns mca1, ClsMns mca2) { return mca1.iX - mca2.iX; });                // 位置の昇順
            //for (int i = 0; i < lstMgcP.Count; i++) { lstMgcP[i].iN = i; }                                  // NoをIndexで振り直し
            int iIdx = 0;
            long iOut = 0L;
            while (true)
            {
                int iBak = iIdx;                                        // 探索Index左端
                int iLeft = lstMgcP[iIdx].iX;                           // 左端の位置
                int iHels = lstMgcP[iIdx].iH;                           // 左端の体力
                int iBCnt = iHels / iA;                                 // 爆破回数
                if (iHels % iA != 0) { iBCnt += 1; }                    // 割り切れなければ+1
                int iDele = iBCnt * iA;                                 // 削除値
                iOut += (long)iBCnt;                                    // 爆破回数合計
                for (; iIdx < lstMgcP.Count; iIdx++)
                {
                    if (lstMgcP[iIdx].iX <= iLeft + iD * 2)
                    {
                        lstMgcP[iIdx].iH -= iDele;
                        if (lstMgcP[iIdx].iH < 0) { lstMgcP[iIdx].iH = 0; }
                    }
                    else { break; }
                }
                for (int i = iBak; i < iIdx; i++)
                {
                    if (lstMgcP[i].iH > 0) { iIdx = i; break; }
                }
                if (iIdx >= lstMgcP.Count) { break; }
            }

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

        // DebugDisp
        private static void DebugDisp(List<List<ClsMns>> lstGrp)
        {
            for (int i = 0; i < lstGrp.Count; i++)
            {
                for (int j = 0; j < lstGrp[i].Count; j++)
                {
                    string sOut = "";
                    //sOut += lstGrp[i][j].iN.ToString("000") + " " + lstGrp[i][j].iX.ToString("000") + " " + lstGrp[i][j].iH.ToString("00000000");
                    System.Console.WriteLine("{0}", sOut.ToString().Trim());
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }

        // Listのコピー
        private static List<ClsMns> fncListCopy(List<ClsMns> lstS)
        {
            List<ClsMns> lstD = new List<ClsMns>();
            for (int i = 0; i < lstS.Count; i++)
            {
                ClsMns oneUsr = new ClsMns();
                //oneUsr.iN = lstS[i].iN;
                oneUsr.iX = lstS[i].iX;
                oneUsr.iH = lstS[i].iH;
                lstD.Add(oneUsr);
            }
            return lstD;
        }

        // Decimal 大小
        private static int DecDaiSyo(decimal a, decimal b)
        {
            int iRet = 0;
            if (a > b) { iRet = +1; }
            if (a < b) { iRet = -1; }
            return iRet;
        }

        // longl 大小
        private static int LngDaiSyo(long a, long b)
        {
            int iRet = 0;
            if (a > b) { iRet = +1; }
            if (a < b) { iRet = -1; }
            return iRet;
        }

        // 怪物情報
        private class ClsMns
        {
            //public int     iN { get; set; } = 0;                // No
            public int     iX { get; set; } = 0;                // 位置
            public int     iH { get; set; } = 0;                // 体力
        }

}