NOIP '99 P3 - Traveller's Budget

View as PDF

Submit solution

Points: 12 (partial)
Time limit: 1.0s
Memory limit: 64M

Problem type

A traveller wants to drive from one city to another with minimum cost (assuming the gas tank is empty at the beginning). Given the distance between two cities is D1, the capacity of the car's fuel tank is C (in litres), the distance that a litre of gasoline can travel is D2, the gas price per litre at the starting point is P, and there are N gas stations along the way, the distance from the gas station i to the starting point is Di, and the price of gasoline per litre is Pi (i=1,2,,N). Round your answer to two decimal places. If the destination cannot be reached, output No Solution.

Constraints

1N6

1D1,C,D2,P,Pi,Di500

Input Specification

The first line contains five space-separated numbers, representing D1, C, D2, P and N, respectively.

The next N lines contain two numbers Di, the distance from the starting point to the gas station i, and Pi, the price of gasoline per litre at the gas station i.

Output Specification

Output the minimum cost required, rounded to two decimal places. If the destination cannot be reached, output No Solution.

Sample Input

Copy
275.6 11.9 27.4 2.8 2
102.0 2.9
220.0 2.2

Sample Output

Copy
26.95

Problem translated to English by Tommy_Shan.


Comments

There are no comments at the moment.