P1180 Self-Driving Tour
Description
Nowadays, many ordinary families own private cars, and some people like to drive themselves from one city to another for travel. When traveling by car, you will always encounter the problems of refueling and eating. Before departure, drivers try to obtain a list of gas stations along the route from one city to another. The list includes the location of every gas station and its price per liter (e.g., $3.25$ yuan/L). Drivers generally have the following habits:
1. The driver never stops at a gas station if there is at least half of the maximum tank capacity left in the tank, unless the car cannot reach the next gas station or the destination with the fuel currently in the tank.
2. At the first gas station where they stop, they always fill the tank to full.
3. While refueling at a gas station, they also buy fast food and other snacks, spending 20 yuan.
4. The tank is always full when departing from the starting city.
5. Payments at gas stations are always precise to $0.1$ yuan (rounded).
6. Drivers know how many kilometers their car can travel per liter of gasoline.
Your task is to write a program to compute the minimum total cost for refueling and food on a self-driving trip from one city to another.
Input Format
- The first line is a real number: the distance from the starting point to the destination (unit: km).
- The second line contains three real numbers and one integer:
1) the maximum capacity of the fuel tank (unit: L);
2) the number of kilometers the car can travel per liter (unit: km/L);
3) the cost when filling the tank to full at the starting city (unit: yuan);
4) an integer between $1$ and $50$, indicating the number of gas stations along the route.
- The next n lines each contain two real numbers: the distance of a gas station from the starting point (unit: km), and the price of gasoline at that station (unit: yuan).
All data items are valid; no error checking is required. Gas stations on a route are sorted in increasing order by their distance from the starting point, and none of them is farther than the destination.
Output Format
Output a single real number: the minimum total cost for refueling and food, accurate to $0.1$ yuan.
Explanation/Hint
Translated by ChatGPT 5