#P7459. [CERC2018] Reservoir Dog

[CERC2018] Reservoir Dog

Description

Translated from [CERC2018] Reservoir Dog.

You take your dog to a reservoir next to your home to play. Your dog likes playing frisbee, but since you are tired of playing frisbee with your dog, you are curious about the total time from when you throw the frisbee to when your dog picks it up and returns to you. So you bring the dog to your side and start the timer. At time TfT_f milliseconds, you throw the frisbee horizontally from height HfH_f millimeters with initial speed VfV_f millimeters per millisecond. Due to gravity, the frisbee’s vertical acceleration is 11 millimeter per millisecond squared.

At time TdT_d milliseconds, you release the dog. The dog’s maximum horizontal speed is VdV_d. The dog runs on an ideal plane, and it is smart enough to know how to minimize the time to catch the frisbee and bring it back to you. To achieve this, the dog can jump up to height HdH_d millimeters, and a vertical jump does not affect its horizontal speed. After the dog catches the frisbee, it immediately runs back to you at full speed. When the dog reaches your position, you stop the timer. Note that you stop the timer even if your dog is in the air; that is, you also stop the timer if the dog is directly above the initial position.

Your dog is special because it can obtain horizontal speed instantly (with no acceleration or deceleration), and it can change the magnitude of its horizontal speed or reverse its horizontal direction even while in the air. Due to gravity, the dog’s vertical acceleration is 33 millimeters per millisecond squared.

For simplicity, assume the sizes of the frisbee and the dog are negligible. You may use the displacement formula s(t)=s0+v0t+0.5at2s(t)=s_0+v_0t+0.5at^2, though how to use it is up to you.

Input Format

The input contains one line with six integers Tf,Vf,Hf,Td,Vd,HdT_f,V_f,H_f,T_d,V_d,H_d.

Output Format

Output the time you measured (in milliseconds). Your answer is accepted if its absolute error does not exceed 10410^{-4}.

1 2 160 20 6 40
31.92569589
1 2 160 10 6 40
21.65591118

Hint

1Tf;Vf,Hf,Td,Vd,Hd106,Hd<Hf,Tf<Td1≤T_f;V_f,H_f,T_d,V_d,H_d≤10^6,H_d<H_f,T_f<T_d.

Clarifications

Q: How does the dog jump?

A: The dog instantly obtains a vertical speed that allows it to reach height HdH_d.

Q: Does the frisbee keep moving after it hits the ground?

A: When the frisbee hits the ground, it stops moving instantly.

Translated by ChatGPT 5