#P2179. [NOI2012] 骑行川藏

    ID: 1113 远端评测题 1000~2000ms 500MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>数学2012NOI 系列Special Judge向量构造

[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 nn segments. Within each segment the road condition can be considered uniform: for the ii-th segment, we are given three parameters si,ki,vis_i,k_i,v_i', where sis_i is the length of the segment, kik_i is the air-drag coefficient for the segment, and viv_i' is the wind speed on the segment (vi>0v_i' \gt 0 means tailwind on that segment; otherwise, it means headwind).

If at some moment his riding speed on this segment is vv, then the magnitude of the air-drag force is F=ki(vvi)2F=k_i(v-v_i')^2 (therefore, if he maintains a constant speed vv over a distance ss, he expends energy (does work) E=ki(vvi)2sE=k_i(v-v_i')^2s).

Suppose Dandan’s energy budget at the start of the day is EUE_U. 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 TT.

Input Format

The first line contains a positive integer nn and a real number EUE_U, representing the number of segments and Dandan’s energy budget, respectively.

The next nn lines describe the nn segments. Each line contains three real numbers si,ki,vis_i,k_i,v_i' representing the length, air-drag coefficient, and wind speed of the ii-th segment.

Output Format

Output a real number TT, the minimal time for Dandan to reach the destination. Keep at least 66 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 5.12939919,8.03515481,6.178379675.12939919, 8.03515481, 6.17837967.

  • Scoring: There are no partial scores. Your output must differ from the standard answer by no more than 10610^{-6} to receive full score on a test point; otherwise you get zero for that point.

  • Constraints: For 10%10\% of the testdata, n=1n=1.

    For 40%40\% of the testdata, n2n\le 2.

    For 60%60\% of the testdata, n100n\le 100.

    For 80%80\% of the testdata, n1000n\le 1000.

    For 100%100\% of the testdata, n104n\le 10^4, EU108E_U\le 10^8, si[0,105]s_i\in[0,10^5], ki(0,15]k_i\in(0,15], vi(100,100)v_i'\in(-100,100).

    The final answer is guaranteed not to exceed 10510^5.

  • Additional hint: There always exists an optimal energy allocation in which Dandan rides at a constant speed on every segment.

Translated by ChatGPT 5