1033. To Fill or Not to Fill (25)
时间限制
10 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
ZHANG, Guochuan
With highways available, driving a car from Hangzhou to any other city is easy. But sincethe tank capacity of a car is limited, we have to find gas stations onthe way fromtimetotime. Different gas station may give different price. You are asked to carefully design the cheapest route to go.
Input Specification:
Each input filecontains one test case. For each case, thefirst line contains4 positive numbers: Cmax (<= 100), the maximum capacity ofthe tank; D (<=30000), the distance between Hangzhou andthe destination city; Davg (<=20), the average distance per unit gas thatthe car can run; and N (<= 500), the total numberof gas stations. Then N lines follow, each contains a pair of non-negative numbers: Pi, the unit gas price, and Di (<=D), the distance between this station and Hangzhou, for i=1,...N. All the numbers in a line are separated by a space.
Output Specification:
For each test case, print the cheapest price in a line, accurate up to2 decimal places. It is assumed thatthe tank is empty atthebeginning. If itis impossible to reach the destination, print "The maximum travel distance = X"where X isthe maximum possible distance the car can run, accurate up to2 decimal places.
Sample Input 1:
5013001286.0012507.006007.001507.1007.202007.504007.3010006.85300
Sample Output 1:
749.17
Sample Input 2:
5013001227.1007.00600
Sample Output 2:
The maximum travel distance = 1200.00