QOJ.ac

QOJ

時間限制: 5 s 記憶體限制: 256 MB 總分: 100

#4749. 定向越野

统计

Khodislav 参加了一场定向越野比赛。比赛场地是一个没有障碍的无限平面,他在所有方向上的移动速度相同。场地内有 $N$ 个检查点,每位参赛者必须按编号升序依次访问这些检查点。签到系统是无接触式的——每个检查点都有一个基站,会自动签到距离小于或等于 $R$ 的任何参赛者。保证检查点的覆盖区域互不重叠,但它们可以相互接触。

参赛者从第一个检查点覆盖区域内的任意一点出发,并在签到最后一个检查点时结束比赛。参赛者在前往目标检查点的途中可以进入其他检查点的覆盖区域,但在这种情况下,他们不会在那些检查点签到。

Khodislav 感觉很幸运,并相信他能够以最优方式完成比赛。请帮他计算他需要行进的最短距离。

输入格式

输入文件的第一行包含两个整数:$N$ —— 检查点的数量($2 \le N \le 100$),以及 $R$ —— 签到半径($1 \le R \le 10^9$)。

接下来的 $N$ 行描述了按要求签到顺序排列的检查点。每行包含一对整数 $x_i, y_i$,表示坐标($-10^9 \le x_i, y_i \le 10^9$)。

输出格式

输出一个实数 —— 如果路线最优,总共需要行进的距离。

相对误差或绝对误差不得超过 $0.01$。这意味着如果最优答案为 $X$,你的答案与 $X$ 的差值不得超过 $\frac{1}{100} \max(X, 1)$。

样例

输入 1

3 3
0 -3
0 100
0 50

输出 1

141.0

说明

Khodislav 从 $(0, 0)$ 出发,在第二个检查点 $(0, 97)$ 处签到,然后转向并在第三个检查点 $(0, 53)$ 处签到。总行进距离为 $97 + 44 = 141$。

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.