Logo
(追記) (追記ここまで)

33374번 - Egg Drop Challenge 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 2048 MB421100.000%

문제

Annual Egg Drop Challenge is about to start! There are $n$ people participating in the challenge. They are standing on different floors of the same building, and the $i$-th of them stands on the $i$-th floor, at a height of $h_i$ above the ground. The person on the $n$-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 $i$ holds an egg in their hands, they can throw it down with any real-valued speed from 0ドル$ to $v_i$.

When the egg flies past person $i,ドル that is, when it is at a height of $h_i,ドル they can (but are not obliged to) catch it if it flies at a speed of at most $u_i$. 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 1ドル$.

When the egg is falling, it falls with the acceleration of free fall $g$. For simplicity of calculations, we will assume that there is no air resistance, and we will also assume that $g=1$. 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 $n,ドル the number of people participating in the challenge (2ドル \le n \le 3 \cdot 10^5$).

The next $n$ lines describe the people participating in the challenge. The $i$-th such line describes person $i$ and contains three integers: $h_i,ドル $v_i,ドル and $u_i$ (1ドル \le h_i \le 10^{18}$; 1ドル \le v_i, u_i \le 10^9$): the height of person $i$ above the ground and the maximum speed with which they can throw and catch an egg, respectively.

It is guaranteed that $h_i < h_{i+1}$ for all 1ドル \le i \le n - 1$.

출력

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 10ドル^{-6}$.

Otherwise, print a line with the number $-1$.

제한

예제 입력 1

5
2 1 7
14 6 4
18 1 7
21 2 5
28 4 10

예제 출력 1

6.00000000000000000000

예제 입력 2

2
1 1 4
10 5 1

예제 출력 2

-1

노트

If the egg starts flying at a speed of $v,ドル then after flying for $t$ seconds, it will move at a speed of $v + g \cdot t,ドル or just $v + t$ in our case, and will cover the total distance of $v \cdot t + g \cdot \frac{t^2}{2},ドル or just $v \cdot t + \frac{t^2}{2}$ in our case.

In the first example, the optimal solution looks as follows:

  • Person 5ドル$ throws the egg at a speed of 4ドル$. After flying for 2ドル$ seconds, it will cover 4ドル \cdot 2 + \frac{2^2}{2}=10$ meters and will be moving at a speed of 6ドル,ドル so person 3ドル$ will be able to catch it.
  • Person 3ドル$ throws the egg at a speed of 1ドル,ドル and after 2ドル$ seconds, person 2ドル$ will catch it.
  • Person 2ドル$ throws the egg at a speed of 5ドル,ドル and after 2ドル$ more seconds, person 1ドル$ will catch it, completing the challenge in 6ドル$ seconds.

In the second example, even if person 2ドル$ throws the egg at a speed of 0ドル,ドル it will still move faster than 4ドル$ when it reaches the first floor. So, safe lowering is impossible.

출처

Camp > Petrozavodsk Programming Camp > Summer 2023 > Day 5: Moscow IPT Yolki-Palki Contest 1 E번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /