output_description: Print the minimum number of bombs needed to win.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N D A
      X_1 H_1
      :
      X_N H_N
attempt: import bisect
  import math
  
  n, d, a = map(int, input().split())
  xh = []
  
  for _ in range(n):
      x, h = map(int, input().split())
      xh.append((x, h))
  xh.sort(key=lambda x: x[0])
  xs = [x[0] for x in xh]
  
  ranges = []
  for x in xs:
      ranges.append(bisect.bisect_right(xs, x + 2 * d))
  
  
  # N: 処理する区間の長さ
  N = n
  INF = 2**31 - 1
  
  LV = (N - 1).bit_length()
  N0 = 2**LV
  data = [0] * (2 * N0)
  lazy = [0] * (2 * N0)
  
  
  def gindex(l, r):
      L = (l + N0) >> 1
      R = (r + N0) >> 1
      lc = 0 if l & 1 else (L & -L).bit_length()
      rc = 0 if r & 1 else (R & -R).bit_length()
      for i in range(LV):
          if rc <= i:
              yield R
          if L < R and lc <= i:
              yield L
          L >>= 1
          R >>= 1
  
  
  # 遅延伝搬処理
  def propagates(*ids):
      for i in reversed(ids):
          v = lazy[i - 1]
          if not v:
              continue
          lazy[2 * i - 1] += v
          lazy[2 * i] += v
          data[2 * i - 1] += v
          data[2 * i] += v
          lazy[i - 1] = 0
  
  
  # 区間[l, r)にxを加算
  def update(l, r, x):
      (*ids,) = gindex(l, r)
      propagates(*ids)
  
      L = N0 + l
      R = N0 + r
      while L < R:
          if R & 1:
              R -= 1
              lazy[R - 1] += x
              data[R - 1] += x
          if L & 1:
              lazy[L - 1] += x
              data[L - 1] += x
              L += 1
          L >>= 1
          R >>= 1
      for i in ids:
          data[i - 1] = min(data[2 * i - 1], data[2 * i])
  
  
  # 区間[l, r)内の最小値を求める
  def query(l, r):
      propagates(*gindex(l, r))
      L = N0 + l
      R = N0 + r
  
      s = INF
      while L < R:
          if R & 1:
              R -= 1
              s = min(s, data[R - 1])
          if L & 1:
              s = min(s, data[L - 1])
              L += 1
          L >>= 1
          R >>= 1
      return s
  
  
  for i, (x, h) in enumerate(xh):
      update(i, i + 1, h)
  
  ans = 0
  for i in range(n):
      v = query(i, i + 1)
      if v > 0:
          t = math.ceil(v / a)
          ans += t
          update(i, ranges[i], -t * a)
  print(ans)
  
problem_description: 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.
samples: [{"input": "3 3 2\n    1 2\n    5 4\n    9 2", "output": "2\n    \n\nFirst, let us use a bomb at the coordinate 4 to decrease the first and second\nmonsters' health by 2.\n\nThen, use a bomb at the coordinate 6 to decrease the second and third\nmonsters' health by 2.\n\nNow, all the monsters' healths are 0. We cannot make all the monsters' health\ndrop to 0 or below with just one bomb.\n\n* * *"}, {"input": "9 4 1\n    1 5\n    2 4\n    3 3\n    4 2\n    5 1\n    6 2\n    7 3\n    8 4\n    9 5", "output": "5\n    \n\nWe should use five bombs at the coordinate 5.\n\n* * *"}, {"input": "3 0 1\n    300000000 1000000000\n    100000000 1000000000\n    200000000 1000000000", "output": "3000000000\n    \n\nWatch out for overflow."}]