国王的问题?AI (CI翻译)
Every true king during his life must conquer the world, hold the Codeforces world finals, win pink panda in the shooting gallery and travel all over his kingdom.
每一位真正的国王在有生之年都必须征服世界、举办 Codeforces 世界总决赛、在射击场赢得粉色熊猫,并游历自己的整个王国。AI (CI翻译)
King Copa has already done the first three things. Now he just needs to travel all over the kingdom. The kingdom is an infinite plane with Cartesian coordinate system on it. Every city is a point on this plane. There are $*n*$ cities in the kingdom at points with coordinates $(*x*_{1}, 0), (*x*_{2}, 0), ..., (*x*_{*n*}, 0)$, and there is one city at point $(*x*_{*n* + 1}, *y*_{*n* + 1})$.
国王 Copa 已经完成了前三件事。现在他只需要游历整个王国。王国是一片带有笛卡尔坐标系的无限平面。每座城市都是平面上的一个点。王国中有 $*n*$ 座城市,坐标分别为 $(*x*_{1}, 0), (*x*_{2}, 0), ..., (*x*_{*n*}, 0)$,还有一座城市位于点 $(*x*_{*n* + 1}, *y*_{*n* + 1})$。AI (CI翻译)
King starts his journey in the city number $*k*$. Your task is to find such route for the king, which visits all cities (in any order) and has minimum possible length. It is allowed to visit a city twice. The king can end his journey in any city. Between any pair of cities there is a direct road with length equal to the distance between the corresponding points. No two cities may be located at the same point.
国王从编号为 $*k*$ 的城市出发。请你为国王规划一条路线,使其按任意顺序访问所有城市,且路线长度尽可能短。允许重复访问城市。国王可以在任意一座城市结束行程。任意两座城市之间都有一条直接道路,其长度等于对应两点之间的距离。任意两座城市都不会位于同一个点上。AI (CI翻译)
Input
输入格式
AI (CI翻译)The first line contains two integers $*n*$ and $*k*$ ($1 ≤ *n* ≤ 10^{5}, 1 ≤ *k* ≤ *n* + 1$) — amount of cities and index of the starting city. The second line contains $*n* + 1$ numbers $*x*_{*i*}$. The third line contains $*y*_{*n* + 1}$. All coordinates are integers and do not exceed $10^{6}$ by absolute value. No two cities coincide.
第一行包含两个整数 $*n*$ 和 $*k*$($1 ≤ *n* ≤ 10^{5}, 1 ≤ *k* ≤ *n* + 1$),分别表示城市数量和出发城市的编号。第二行包含 $*n* + 1$ 个数 $*x*_{*i*}$。第三行包含 $*y*_{*n* + 1}$。所有坐标均为绝对值不超过 $10^{6}$ 的整数。任意两座城市都不重合。AI (CI翻译)
Output
输出格式
AI (CI翻译)Output the minimum possible length of the journey. Your answer must have relative or absolute error less than $10^{ - 6}$.
输出行程的最短可能长度。你的答案的相对误差或绝对误差必须小于 $10^{ - 6}$。AI (CI翻译)
样例
3 1
0 1 2 1
1
3.41421356237309490000
3 1
1 0 2 1
1
3.82842712474619030000
4 5
0 5 -1 -5 2
3
14.24264068711928400000
题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。