#P3957. [NOIP 2017 普及组] 跳房子
[NOIP 2017 普及组] 跳房子
Description
Hopscotch, also called “jumping the airplane,” is a worldwide children’s game and one of China’s traditional folk sports.
The rules of hopscotch are as follows:
On the ground, fix a starting point, and then draw cells to the right of the start point along a straight line. Each cell contains an integer, which is the score awarded upon reaching that cell. The player starts at the start point and, on the first jump, jumps to a cell to the right of the start point. On the second jump, the player continues jumping to the right from the current position, and so on. The rules state:
- On every jump, the player must land on a cell strictly to the right of the current position. The player may end the game at any time. The final score is the sum of the numbers in all cells that have ever been reached.
Now, Xiao R has developed a bouncing robot to play this game. However, the robot has a very serious flaw: each time it jumps to the right, the distance can only be a fixed . Xiao R wants to improve his robot. If he spends gold coins to improve the robot, its flexibility increases by . Note that each jump distance must be at least . Specifically, when , the robot can choose its rightward jump distance each time from ; otherwise, when , the robot can choose its rightward jump distance each time from .
Now Xiao R wants to obtain at least points. What is the minimum number of gold coins he must spend to modify his robot?
Input Format
The first line contains three positive integers , representing the number of cells, the robot’s fixed jump distance before improvement, and the desired score (at least ). The numbers are separated by a single space.
The next lines each contain two integers , representing the distance from the start point to the -th cell and the score of the -th cell. The two numbers are separated by a single space. It is guaranteed that are given in increasing order.
Output Format
Output a single integer: the minimum number of gold coins required to modify the robot. If it is impossible to obtain at least points under any circumstances, output .
7 4 10
2 6
5 -3
10 3
11 -3
13 1
17 6
20 2
2
7 4 20
2 6
5 -3
10 3
11 -3
13 1
17 6
20 2
-1
Hint
- Sample 1 explanation
After spending gold coins on improvements, Xiao R’s robot chooses rightward jump distances in order, reaching positions , which correspond to cells . The sum of the numbers in these cells is , which is the score obtained by Xiao R.
- Sample 2 explanation
Since the maximum possible sum of the numbers of any subset of the cells in the sample is only , it is impossible to obtain points.
- Constraints
There are groups of testdata, each accounting for an equal proportion.
For all testdata, , , , .
For testdata groups and , .
For testdata groups , , and , .
For testdata groups , , and , .
Translated by ChatGPT 5
京公网安备 11011102002149号