QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 512 MB Puntuación total: 100

#10452. Cycling Sichuan-Tibet

Estadísticas

Dandan is very keen on challenging himself. This summer, he plans to ride his bicycle along the Sichuan-Tibet line from Chengdu to Lhasa. The scenery along the Sichuan-Tibet line is beautiful, but there are also many difficulties and obstacles, and the road conditions are ever-changing. Since Dandan's physical strength is limited, it is very important to set a destination and allocate his physical strength reasonably before each day's ride.

Because Dandan is equipped with a very good bicycle, it can be assumed that during the ride, he only does work to overcome wind resistance (ignoring the friction of the bicycle itself and the friction between the bicycle and the ground). One day, he plans to ride through $N$ segments, and the road conditions within each segment can be considered uniform. For the $i$-th segment, we are given 3 parameters $s_i, k_i, v_i'$, where $s_i$ represents the length of this segment, $k_i$ represents the wind resistance coefficient of this segment, and $v_i'$ represents the wind speed on this segment ($v_i' > 0$ means he encounters a tailwind on this segment, while otherwise, it means he will be affected by a headwind). If his riding speed on this segment at any moment is $v$, the wind resistance he experiences is $F = k_i(v - v_i')^2$ (thus, if he maintains a constant riding speed $v$ over a distance $s$, the energy he consumes (work done) is $E = k_i(v - v_i')^2 s$).

Given that Dandan's initial energy level for the day is $E_U$, please help him design a riding plan so that he can reach his destination in the shortest time with his limited physical strength. Please tell him what the shortest time $T$ is.

Input

The first line contains a positive integer $N$ and a real number $E_U$, representing the number of segments and Dandan's energy level, respectively.

The next $N$ lines each describe one of the $N$ segments, with each line containing 3 real numbers $s_i, k_i, v_i'$, representing the length, wind resistance coefficient, and wind speed of the $i$-th segment, respectively.

Output

Output a single real number $T$, representing the shortest time for Dandan to reach the destination, rounded to at least 6 decimal places.

Examples

Input 1

3 10000
10000 10 5
20000 15 8
50000 5 6

Output 1

12531.34496464

Note

One possible plan is: Dandan maintains a constant speed on all three segments, with speeds of $5.12939919$, $8.03515481$, and $6.17837967$ respectively.

Subtasks

There are no partial points for this problem. Your program will only receive full marks for a test case if the difference between your output and the standard answer does not exceed $0.000001$; otherwise, you will receive no points.

Constraints

For 10% of the data, $N = 1$; For 40% of the data, $N \le 2$; For 60% of the data, $N \le 100$; For 80% of the data, $N \le 1000$; For all data, $N \le 10000$, $0 \le E_U \le 10^8$, $0 < s_i \le 100000$, $0 < k_i \le 15$, $-100 < v_i' < 100$. The data guarantees that the final answer will not exceed $10^5$.

Note

There must exist an optimal energy plan such that Dandan maintains a constant speed on each segment.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.