#P2179. [NOI2012] 骑行川藏
[NOI2012] 骑行川藏
Description
Dandan is very enthusiastic about challenging himself. This summer vacation he plans to ride a bicycle along the Sichuan–Tibet route from Chengdu to Lhasa.
The scenery along the Sichuan–Tibet route is beautiful, but there are many difficulties and changing road conditions along the way. Dandan’s stamina is limited, so before each day’s ride he sets a destination for the day and allocates his energy reasonably, which is very important.
Because Dandan is equipped with a very good bicycle, we can assume that during the ride he only does work to overcome air resistance (he is not affected by friction inside the bicycle or between the bicycle and the ground).
On a certain day he plans to ride segments. Within each segment the road condition can be considered uniform: for the -th segment, we are given three parameters , where is the length of the segment, is the air-drag coefficient for the segment, and is the wind speed on the segment ( means tailwind on that segment; otherwise, it means headwind).
If at some moment his riding speed on this segment is , then the magnitude of the air-drag force is (therefore, if he maintains a constant speed over a distance , he expends energy (does work) ).
Suppose Dandan’s energy budget at the start of the day is . Please help him design a riding plan so that he reaches the destination in the shortest possible time within his energy budget. Please output the minimal time .
Input Format
The first line contains a positive integer and a real number , representing the number of segments and Dandan’s energy budget, respectively.
The next lines describe the segments. Each line contains three real numbers representing the length, air-drag coefficient, and wind speed of the -th segment.
Output Format
Output a real number , the minimal time for Dandan to reach the destination. Keep at least digits after the decimal point.
3 10000
10000 10 5
20000 15 8
50000 5 6
12531.34496464
Hint
-
Sample explanation: One possible plan is: Dandan rides at a constant speed on each of the three segments, with speeds .
-
Scoring: There are no partial scores. Your output must differ from the standard answer by no more than to receive full score on a test point; otherwise you get zero for that point.
-
Constraints: For of the testdata, .
For of the testdata, .
For of the testdata, .
For of the testdata, .
For of the testdata, , , , , .
The final answer is guaranteed not to exceed .
-
Additional hint: There always exists an optimal energy allocation in which Dandan rides at a constant speed on every segment.
Translated by ChatGPT 5
京公网安备 11011102002149号