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.Linq;
using System.Collections.Generic;

namespace Contest
{
    partial class Program
    {
        static void Main(string[] args)
        {
            ABC153_F();
        }


        static void ABC153_A()
        {
            var ha = ReadIntN();
            Console.WriteLine((ha[0] + ha[1] - 1) / ha[1]);
        }
        static void ABC153_B()
        {
            var hn = ReadIntN();
            var a = ReadIntN();
            Console.WriteLine(hn[0] <= a.Sum() ? "Yes" : "No");
        }
        static void ABC153_C()
        {
            var nk = ReadIntN();
            var h = ReadLongN();
            var N = nk[0];
            var K = nk[1];
            h = h.OrderBy(x => x).ToArray();
            Console.WriteLine(h.Take(N <= K ? 0 : N - K).Sum());
        }
        static void ABC153_D()
        {
            var H = ReadLong();
            long n = 1;
            while (H >= n)
            {
                n *= 2;
            }
            Console.WriteLine(n - 1);
        }
        static void ABC153_E()
        {
            var hn = ReadIntN();
            int H = hn[0];
            int N = hn[1];
            var ab = ReadTupleLong(N);
            var A = ab.Select(x => x.Item1).ToArray();
            var B = ab.Select(x => x.Item2).ToArray();
            long[] minMagic = new long[H + 1];
            minMagic[0] = 0;
            for(int i = 1; i < minMagic.Length; ++i)
            {
                minMagic[i] = Int32.MaxValue;
                for(int n = 0; n < N; ++n)
                {
                    var h0 = A[n] >= i  ? 0 : minMagic[i - A[n]];
                    minMagic[i] = Math.Min(minMagic[i], B[n] + h0);
                }
            }
            Console.WriteLine(minMagic[H]);
        }
        static void ABC153_F()
        {
            var nda = ReadIntN();
            var N = nda[0];
            var D = nda[1];
            var A = nda[2];
            var xh = ReadTupleLong(N).OrderBy(x => x.Item1).ToArray();
            var h = xh.Select(x => x.Item2).ToArray();
            long sum = 0;
            for(int i = 0; i < N; ++i)
            {
                var bomb = (Math.Max(0, h[i]) + A - 1) / A;
                sum += bomb;
                if (bomb >= 0)
                {
                    for (int j = i; j < N; ++j)
                    {
                        if (xh[j].Item1 - xh[i].Item1 <= D * 2)
                        {
                            h[j] -= bomb * A;
                        }
                        else { break; }
                    }
                }
            }
            Console.WriteLine(sum);
        }

        static string ReadStr()
        {
            return Console.ReadLine();
        }
        static string[] ReadStrN()
        {
            return Console.ReadLine().Split(' ');
        }
        static int ReadInt()
        {
            return Convert.ToInt32(Console.ReadLine());
        }
        static int[] ReadIntN()
        {
            return Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
        }
        static long ReadLong()
        {
            return Convert.ToInt64(Console.ReadLine());
        }
        static long[] ReadLongN()
        {
            return Console.ReadLine().Split(' ').Select(s => Convert.ToInt64(s)).ToArray();
        }
        static Tuple<long, long>[]  ReadTupleLong(int n)
        {
            List<Tuple<long, long>> list = new List<Tuple<long, long>>();
            for (int i = 0; i < n; ++i)
            {
                var ab = ReadLongN();
                list.Add(new Tuple<long, long>(ab[0], ab[1]));
            }
            return list.ToArray();
        }
    }
}