1033. To Fill or Not to Fill (25)
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.
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.
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:
Sample Output 1:
Sample Input 2:
Sample Output 2:
The maximum travel distance = 1200.00