QOJ.ac

QOJ

Time Limit: 3 s Memory Limit: 512 MB Total points: 100

#17185. 1D City

Statistics

City S is a one-dimensional city, and its coordinate system is identical to the number line. There are $n$ key points located at $x_1, \dots, x_n$. Any position at a distance $< r$ from any key point is forbidden (positions at distance $= r$ are allowed). Little Q is initially at coordinate $A$ in City S. He can perform the following actions:

  • Walk from $x$ to $y$, which consumes $|x-y|$ time. This operation requires passing through all real-numbered points between $x$ and $y$, so it must be guaranteed that there are no forbidden points in the interval between $x$ and $y$.
  • Jump from $x$ to $x+2R$, which consumes $\pi \cdot R$ time. This operation only requires that $x$ and $x+2R$ are allowed positions.
  • Jump from $x$ to $x-2R$, which consumes $\pi \cdot R$ time. This operation only requires that $x$ and $x-2R$ are allowed positions.

Given $n, r, R, A, B$, and $x_1, \dots, x_n$, find the minimum time for Little Q to reach $B$. If it is impossible to reach $B$, output $-1$. It is guaranteed that $A$ and $B$ are both allowed positions.

This problem allows a relative error of $10^{-6}$. If your output is $p$ and the true answer is $q$, your answer is considered correct if $\dfrac{|p-q|}{\max(1,|q|)} \le 10^{-6}$.

Input

The first line contains five integers $n, r, R, A, B$.

The second line contains $n$ integers $x_1, \dots, x_n$.

Output

A single real number representing the answer.

Examples

Input 1

5 2 5 3 9
13 0 17 7 18

Output 1

55.1238898038

Constraints

For $100\%$ of the data, $1 \le n \le 500$, $1 \le r \le R \le 10^6$, $-10^9 \le A \le B, x_i \le 10^9$.

  • Subtask 1 ($30\%$): $-10^5 \le r, R, A, B, x_i \le 10^5$.
  • Subtask 2 ($30\%$): $n \le 50$.
  • Subtask 3 ($40\%$): No special restrictions.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.