Jumping Path
Time limit2sMemory limit1024 MB
Popeye walks along a line with n forbidden zones and may jump over each zone with a pole of length R, so find the minimum time from A to B.
- Level
Medium6 of 10
- Topics
- Sorting, Greedy, Implementation, Math
- Solved
- No attempts yet
Statement
Popeye the Sailor loves to eat spinach. He also loves to smoke his corn-made pipe, and he smokes it constantly.
Popeye lives in the village of Sweethaven. The main street of Sweethaven is a straight line with public places, located at coordinates on that line.
Popeye needs to get from point on the main street to point . The Sweethaven authority has passed a law: smoking closer than to a public place is prohibited. Popeye has a pole of length , so he can jump over the forbidden zones.
Popeye starts at point . He can walk from to in time. At any time, he can use the pole to move from to or along a semicircle of radius , which takes time. At the end, Popeye must be at point , and no point on his trajectory can be closer than to any public place.
Input
The first line contains five integers , , , , and (, , ). The second line contains integers (). All are pairwise distinct. Points and are different, and neither lies in a forbidden zone.
Output
Print one real number, the smallest time. The answer is accepted if its absolute or relative error is at most . If it is impossible to get from to , print .
Hint
In the example from the statement, one of the optimal trajectories is shown below. The elapsed time is .
