Ghost of Kyiv
Limits: 1 sec., 256 MiB
This statement was translated automatically from Ukrainian.
Few people know that the Ghost of Kyiv is actually Zenik. Zenik’s plane is equipped with missiles that deal \(a\) damage. Zenik’s plane also has \(b\) health. No one knows whether the Ghost of Kyiv is still alive or not. However, it is known that Zenik was alive until the last time there was an enemy attack. In that air battle, Zenik was opposed by \(n\) enemy planes. It is known that the \(i\)-th plane was equipped with missiles dealing \(d_i\) damage, and the health of this plane was \(h_i\). Zenik is a very skilled pilot, and therefore he lured out the enemy planes one by one in a given order.
The battle between two planes proceeds as follows: the planes take turns firing missiles at each other until the health of one of the planes is no longer positive. Zenik controls his plane much better than any enemy pilot, so he will always fire his missiles first.
Tell whether Zenik’s plane remained intact after all the air battles?
Input
The first line gives three integers \(n\), \(a\) and \(b\) — the number of enemy planes, the damage of Zenik’s plane missiles, and the health of Zenik’s plane.
The next \(n\) lines each specify two integers \(d_i\) and \(h_i\) — the damage of the \(i\)-th enemy plane’s missiles and its health.
Output
Output Yes if Zenik’s plane survived and No
otherwise.
Constraints
\(1 \le n\le 10^{3}\),
\(1 \le a\le 10^{3}\),
\(1 \le b\le 10^{9}\),
\(0 \le d_i,h_i \le 10^{3}\),
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 3 4 15 4 2 9 5 5 3 | Yes |
| Input (stdin) | Output (stdout) |
|---|---|
| 3 2 10 3 4 1 6 7 3 | No |
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
Ghost of Kyiv - Editorial
To destroy the \(i\)-th enemy plane,
Zenyk needs to make \(\lceil \frac{h_i}{a}
\rceil\) hits. And for Zenyk not to be shot down, his plane must
withstand the return fire, which is \(\lceil
\frac{h_i}{a} \rceil - 1\) shots. The total damage to Zenyk’s
plane in this duel is \((\lceil \frac{h_i}{a}
\rceil - 1) \cdot d_i\). So we keep track of how much durability
Zenyk’s plane has left and subtract the total damage. If after some air
battle its durability is less than or equal to 0, Zenyk’s plane cannot
survive, and the answer is No. If this does not happen, his
plane is intact, and we print Yes.
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|