National Olympiad in Informatics, China, 2011
DanDan is always interested in challenging himself. This summer, he prepares to cycle along the Sichuan-Tibet highway to reach Lhasa. It is widely known that the Sichuan-Tibet Highway is filled with hauntingly beautiful scenery, but also happens to contain many dangerous obstacles. DanDan's physical abilities are very limited, so before every day of cycling, he will plan his destination ahead of time. Appropriately distributing the workload is a very critical matter.
DanDan has a cutting-edge bicycle. Riding it, the only thing he has to worry about is air resistance (he will not at all be affected by the friction of the bicycle, nor the friction between the bicycle and the ground). One day, he decided to cycle sections of road. All of the road in any given section can be considered identical. For the -th section, we assign three parameters , , and . Here, represents the length of the road, represents the coefficient of air resistance, and represents the velocity of the wind on that section of road ( indicates that the wind is blowing in the direction being traveled, while the opposite means that the wind is blowing against the direction being traveled). At a given moment, if the bicycle travels at a velocity of , then the force of air resistance it experiences is . This way, if a section of road of length was traveled at a constant velocity of , then the energy consumed (work done) is .
Let represent DanDan's initial energy at the start of the day. Please help him devise a cycling plan such that he arrives at his destination as soon as possible. DanDan would like to know the value of the shortest possible time .
Input Specification
The first line of input contains a positive integer and a real
number , respectively representing the number of road sections
and DanDan's initial energy.
For the following lines, each line will describe a single road
section. Each line contains real numbers , , and
, respectively representing the -th road section's length,
coefficient of air resistance, and wind velocity.
Output Specification
Output a single real number to at least 6 decimal places, representing the minimum time it will take for DanDan to reach his destination. Your answer will be considered correct if it differs from the actual answer by no more than .
Sample Input
3 10000
10000 10 5
20000 15 8
50000 5 6
Sample Output
12531.34496464
Explanation
One valid way is to ride uniformly on each section of road. The speeds are respectively , , and .
Constraints
For of the test cases, .
For of the test cases, .
For of the test cases, .
For of the test cases, .
For all of the test cases, ,
and . It is guaranteed that answers will not exceed .
Hint
There will always exist an optimal method where DanDan rides with uniform velocity on all sections.
Problem translated to English by .
Comments