Jumping Path

시간 제한2초메모리 제한1024 MB

요약
일직선 위 n개 공공장소 반경 r 안에서는 흡연이 금지될 때, 길이 2R 반원 점프(비용 pi*R)를 섞어 A에서 B까지 가는 최소 시간을 구한다.
난이도

어려움10점 중 8점

유형
최단 경로, 그래프, 기하, 구현
정답자
아직 제출이 없습니다

문제

Popeye the Sailor loves to eat spinach. He also loves to smoke his corn-made pipe. And which he constantly smokes.

Popeye lives in the Sweethaven village. On the main street of Sweethaven, which can be represented as a straight line, there are nn public places, which can be considered as points on a straight line located at coordinates x_1,x_2,⋯ ,x_nx\_1, x\_2, \cdots , x\_n, respectively.

Popeye needs to get from the AA point on the main street to the BB point. Everything would have been simple, if not for the law that passed Sweethaven's authority: now smoking nearer than rr from a public place is prohibited. Fortunately, Popeye has a pole length R≥rR \ge r,, with which he can jump over forbidden zones.

Popeye is initially located at point AA. He can move from xx to yy on foot in ∣x−y∣|x-y| time. Also, at any time, he can use the pole and move from point xx to point x+2Rx+2R or x−2R x-2R, moving along a semicircle of radius RR, while he spends πR\pi R time. At the end of the path, Popeye must be at point BB, and at no point on the trajectory of Popeye can be closer than rr to any public place.

Determine the shortest time it takes Popeye to get from AA to BB. Or determine that it is impossible to get from AA to BB under the given constraints, so Popeye will have to use the power of spinach.

입력

The first line contains five integers nn, rr, RR, AA and BB (1≤n≤5001 \le n \le 500, 1≤r≤R≤1061 \le r \le R \le 10^6, −109≤A,B≤109-10^9 \le A, B \le 10^9). The second line contains nn integers x_1,x_2,⋯ ,x_nx\_1, x\_2, \cdots , x\_n (−109≤x_i≤109-10^9 \le x\_i \le 10^9, 1≤i≤n1 \le i \le n). All x_ix\_i are pairwise distinct. It is guaranteed that the points AA and BB are different and are not located in any of the forbidden zones.

출력

Print one real number --- the smallest time. The answer will be counted if it differs from the jury's answer by no more than 10−610^{-6} in absolute or relative value. If it is impossible to get from AA to BB, print −1-1.

힌트

For an example from the statement, one of the optimal trajectories of movement looks as follows:

Elapsed time --- 8+15π8 + 15\pi.

예제1

  1. 예제 1

    입력
    5 2 5 3 9
    13 0 17 7 18
    
    예상 출력
    55.1238898038