Problem:
Score : 100 points

Problem Statement

Serval is fighting with a monster.

The health of the monster is H.

In one attack, Serval can decrease the monster's health by A.
There is no other way to decrease the monster's health.

Serval wins when the monster's health becomes 0 or below.

Find the number of attacks Serval needs to make before winning.

Constraints

1 \leq H \leq 10^4

1 \leq A \leq 10^4

All values in input are integers.

Input

Input is given from Standard Input in the following format:

H A

Output

Print the number of attacks Serval needs to make before winning.

Sample Input 1

10 4

Sample Output 1

3

After one attack, the monster's health will be 6.

After two attacks, the monster's health will be 2.

After three attacks, the monster's health will be -2.

Thus, Serval needs to make three attacks to win.

Sample Input 2

1 10000

Sample Output 2

1

Sample Input 3

10000 1

Sample Output 3

10000

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Runtime Error)

import java.util.*;
import java.io.*;

public class Main {

  void solve(InputReader in, PrintWriter out) {
    int n = in.nextInt();
    int d = in.nextInt();
    int a = in.nextInt();
    
    Pair[] arr = new Pair[n];
    for (int i = 0; i < n; ++i)
      arr[i] = new Pair(in.nextInt(), in.nextInt());

    Arrays.sort(arr);
    ArrayDeque<Pair> q = new ArrayDeque<>();
    int i = 0; 
    long ans = 0;
    while (i < n) {
      int size = q.size();
      while (size--> 0) {
        Pair p = q.poll();
        if (p.f < arr[i].f) {
          continue;
        }

        arr[i].s -= p.s;
        q.offer(p);
      }
      if (arr[i].s > 0) {
        int attacks = arr[i].s / a;
        attacks += arr[i].s % a != 0 ? 1 : 0;
        ans += attacks;
        q.offer(new Pair(arr[i].f + d + d, attacks * a));
      }
      ++i;
    }

    out.println(ans);
  }

  public static void main(String[] args) throws Exception {
    InputReader in = new InputReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    Main solver = new Main();
    solver.solve(in, out);
    out.close();
  }

  static class Pair implements Comparable<Pair> {
    int f, s;

    public Pair(int f, int s) {
      this.f = f;
      this.s = s;
    }

    @Override
    public int compareTo(Pair p) {
      return this.f - p.f;
    }
  }

  static class InputReader {
    BufferedReader in;
    StringTokenizer st;

    public InputReader(InputStream is) {
      in = new BufferedReader(new InputStreamReader(is));
    }

    public String next() {
      try {
        while (st == null || !st.hasMoreTokens()) {
          st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }
  }
}