#P7480. Reboot from Blue
Reboot from Blue
Description
There are gas stations on a number line. The -th station is at position , and its price is yuan per liter.
At the beginning, YSGH and his car are at position , and he wants to go to position (). The fuel tank is empty at the start, and it is guaranteed that there is a gas station at position .
Assume the car’s fuel tank capacity is unlimited, and liter of fuel can travel a distance of .
He wants to know the minimum cost he needs to pay.
Input Format
The first line contains three integers , with the same meaning as in the statement.
The next lines each contain two integers , representing the price and position of the -th gas station, respectively.
Output Format
Only one line, containing one integer, which is the answer.
3 5 10
10 5
2 4
1 7
19
Hint
Sample Explanation
The optimal plan is to buy liter of fuel at the first gas station to reach the second gas station.
Buy liters at the second gas station to reach the third gas station.
Buy liters at the third gas station to reach the destination.
The answer is .
Constraints
This problem uses bundled testdata.
For of the testdata, , , , , and it is guaranteed that there is a gas station at position .
- Subtask 1 (10 points): .
- Subtask 2 (30 points): .
- Subtask 3 (20 points): is uniformly random in .
- Subtask 4 (40 points): No special constraints.
Translated by ChatGPT 5
京公网安备 11011102002149号