Rally
Time limit6sMemory limit128 MB
Choose a subset of at most 25 stations and fuel amounts to minimize total driving time plus refueling stops.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Implementation, Math
- Solved
- No attempts yet
Problem
You are preparing for a car rally and must decide at which stations along the course to refuel.
The rules are:
- Refueling at a station takes minutes ().
- The tank holds at most liters ().
- At the end of every kilometer driven, the fuel level instantly drops by liters ().
- The car's speed , in kilometers per minute, rises as the fuel level falls, but with an empty tank the car does not move at all: where , , and the data always keeps while (that is, ). The fuel level is constant during a kilometer, so driving that kilometer takes minutes.
- The rally is kilometers long ().
- There are fuel stations ().
- Station is kilometers from the start (, and whenever ).
The car begins at kilometer with a tank you fill for free and finishes at kilometer . You may refuel at any subset of the stations, adding any amount of fuel that keeps the tank within its capacity; each refueling stop costs minutes. The total time is the driving time (the sum of over all kilometers) plus for every refueling stop you make.
Compute the minimum total time in which the rally can be completed.
Input
The input contains the following integers, each on its own line, in this order: , , , , , , , and then .
Output
Print one line: the minimum total time in minutes, rounded to exactly six digits after the decimal point.