QOJ.ac

QOJ

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

#17185. 一维城市

统计

题目描述

S 市是一座一维城市,它的坐标体系与数轴相同。其中有 $n$ 个关键点,分别位于 $x_1,\dots,x_n$,任何与某个关键点距离 $< r$ 的位置都是禁止到达的($=r$ 不禁止)。小 Q 初始位于 S 市坐标 $A$ 处,他可以采取以下几种行动:

  • 从 $x$ 行走到 $y$,需要消耗 $|x-y|$ 的时间。这个操作需要经过 $x,y$ 之间的所有实数点,因此必须保证其中没有禁止到达的点。
  • 从 $x$ 跳跃到 $x+2R$,需要消耗 $\pi\cdot R$ 的时间。这个操作只需要保证 $x,x+2R$ 允许到达。
  • 从 $x$ 跳跃到 $x-2R$,需要消耗 $\pi\cdot R$ 的时间。这个操作只需要保证 $x,x-2R$ 允许到达。

给定 $n,r,R,A,B,x_1,\dots,x_n$。求小 Q 到达 $B$ 的最短时间,若无法到达则输出 $-1$。保证 $A,B$ 均允许到达。

本题允许 $10^{-6}$ 的相对误差。令你输出的答案为 $p$,真实答案为 $q$,则只要 $\dfrac{|p-q|}{\max(1,|q|)}\le 10^{-6}$ 就算作答案正确。

输入格式

第一行,五个整数 $n,r,R,A,B$。

第二行,$n$ 个整数 $x_1,\dots,x_n$。

输出格式

一行,一个实数,表示答案。

样例

样例输入 1

5 2 5 3 9
13 0 17 7 18

样例输出 1

55.1238898038

数据范围

对于 $100\%$ 的数据,$1\le n\le 500$,$1\le r\le R\le 10^6$,$-10^9\le A\le B,x_i\le 10^9$。

$\text{Subtask 1}(30\%):-10^5\le r,R,A,B,x_i\le 10^5$。

$\text{Subtask 2}(30\%):n\le 50$。

$\text{Subtask 3}(40\%):$ 无特殊限制。

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.