Egg Drop Challenge
시간 제한4초메모리 제한2048 MB
각 층의 사람마다 던지는 속도와 받는 속도 한계가 주어질 때, n층에서 1층까지 달걀을 가장 빠르게 옮기는 시간을 구한다.
문제
Annual Egg Drop Challenge is about to start! There are people participating in the challenge. They are standing on different floors of the same building, and the -th of them stands on the -th floor, at a height of above the ground. The person on the -th floor is holding an egg. The task of the participants is to safely lower this egg to the first floor as quickly as possible.
When person holds an egg in their hands, they can throw it down with any real-valued speed from to .
When the egg flies past person , that is, when it is at a height of , they can (but are not obliged to) catch it if it flies at a speed of at most . Catching the egg means completely stopping it. The egg is considered to be safely lowered to the first floor when it was caught by person .
When the egg is falling, it falls with the acceleration of free fall . For simplicity of calculations, we will assume that there is no air resistance, and we will also assume that . In the Note section below, you can find equations that describe the motion of the egg under such assumptions. Catching and throwing are assumed to happen instantly.
Help the participants find the shortest time possible to safely lower the egg to the first floor, or tell them that it is impossible to do so.
입력
The first line contains a single integer , the number of people participating in the challenge ().
The next lines describe the people participating in the challenge. The -th such line describes person and contains three integers: , , and (; ): the height of person above the ground and the maximum speed with which they can throw and catch an egg, respectively.
It is guaranteed that for all .
출력
If it is possible to lower an egg to the first floor by satisfying all the constraints, print a line with one real number: the minimum time it takes to do this. The answer will be considered correct if the absolute or relative error does not exceed .
Otherwise, print a line with the number .
힌트
If the egg starts flying at a speed of , then after flying for seconds, it will move at a speed of , or just in our case, and will cover the total distance of , or just in our case.
In the first example, the optimal solution looks as follows:
- Person throws the egg at a speed of . After flying for seconds, it will cover meters and will be moving at a speed of , so person will be able to catch it.
- Person throws the egg at a speed of , and after seconds, person will catch it.
- Person throws the egg at a speed of , and after more seconds, person will catch it, completing the challenge in seconds.
In the second example, even if person throws the egg at a speed of , it will still move faster than when it reaches the first floor. So, safe lowering is impossible.