[ABC315F] Shortcuts
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
[ABC315F] Shortcuts
题面翻译
对于平面坐标上 个点,输出从 走到 的代价。两点直线距离为欧几里得距离。
正常来讲,你的路径应该为 ,你的代价即为你走过的距离。
但是你被允许跳过一些点,使路径变为 $1\to 2\to \cdots \to (x-1) \to (x+1) \to \cdots \to (n-1) \to n$,跳过的点数不限,但 号点和 号点不能被跳过。
跳过操作需要花费,此时你的代价为你走过的距离加跳过产生的花费。
跳过的花费如下定义:
对于整个旅途,如果你跳过 个点,设花费为 ,
- 时 ;
- 时 。
输出从 走到 的最小代价。保留6位小数。
题目描述
There is a race through checkpoints in this order on a coordinate plane. The coordinates of checkpoint are , and all checkpoints have different coordinates.
Checkpoints other than checkpoints and can be skipped. However, let be the number of checkpoints skipped, and the following penalty will be imposed:
- if , and
- if .
Let be the total distance traveled (Euclidean distance) from checkpoint to checkpoint plus the penalty. Find the minimum achievable value as .
输入格式
输入格式如下:
输出格式
输出最小代价,保留6位小数。
样例 #1
样例输入 #1
6
0 0
1 1
2 0
0 1
1 0
2 1
样例输出 #1
5.828427
样例 #2
样例输入 #2
10
1 8
3 7
9 4
4 9
6 1
7 5
0 0
1 3
6 8
6 4
样例输出 #2
24.634414
样例 #3
样例输入 #3
10
34 24
47 60
30 31
12 97
87 93
64 46
82 50
14 7
17 24
3 78
样例输出 #3
110.612384
提示
数据范围
- 输入都是整数
- 时
Sample Explanation 1
点 通过, 跳过。 - 移动。 点间距离为 。 - 移动。 点间距离为 。 - 移动。 点间距离为 。 - 由于跳过了2个点,故 。 可以证明此时 取到最小。
9月19日周二晚上集训赛
- Status
- Done
- Rule
- IOI
- Problem
- 8
- Start at
- 2023-9-19 19:00
- End at
- 2023-9-19 21:00
- Duration
- 2 hour(s)
- Host
- Partic.
- 30