Author: | A. Verkholat | Time limit: | 1 sec | |
Input file: | Standard input | Memory limit: | 256 Mb | |
Output file: | Standard output |
Jora is playing a game called Jora vs Zombies.
His character is positioned at coordinate 0.
Each second, Jora’s weapon can deal D damage to the nearest zombie within a radius of R.
If multiple zombies are equidistant, the damage is dealt to a random one.
A zombie dies when its health drops to zero.
Additionally, each second, zombies move one coordinate closer to Jora (after the weapon fires during that second).
The game is considered lost if any zombie reaches Jora’s position.
Your task is to determine if Jora can win the game. If he can, calculate the number of seconds required to eliminate all the zombies.
The first line contains three integers N, D, and R:
N - number of zombies.
D - damage dealt by the weapon per second.
R - weapon's effective radius.
The following N lines describe each zombie with two integers Xi and Hi:
Xi - initial coordinate of the i-th zombie.
Hi - health of the i-th zombie.
Output a single integer - the number of seconds required to eliminate all zombies.
If it is impossible to win, output -1.
1 ≤ N ≤ 105
1 ≤ R, D, Xi, Hi ≤ 109
No. | Standard input | Standard output |
---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|