CF671A.Recycling Bottles
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
It was recycling day in Kekoland. To celebrate it Adil and Bera went to Central Perk where they can take bottles from the ground and put them into a recycling bin.
We can think Central Perk as coordinate plane. There are n bottles on the ground, the i-th bottle is located at position (x__i, y__i). Both Adil and Bera can carry only one bottle at once each.
For both Adil and Bera the process looks as follows:
- Choose to stop or to continue to collect bottles.
- If the choice was to continue then choose some bottle and walk towards it.
- Pick this bottle and walk to the recycling bin.
- Go to step 1.
Adil and Bera may move independently. They are allowed to pick bottles simultaneously, all bottles may be picked by any of the two, it's allowed that one of them stays still while the other one continues to pick bottles.
They want to organize the process such that the total distance they walk (the sum of distance walked by Adil and distance walked by Bera) is minimum possible. Of course, at the end all bottles should lie in the recycling bin.
今天是克克兰德的回收日。为了庆祝这一天,阿迪尔和贝拉来到了中央公园咖啡馆(Central Perk),在那里他们可以从地上拾起瓶子并将其投入回收箱。
我们可以将中央公园咖啡馆建模为一个二维坐标平面。地面上共有 n 个瓶子,其中第 i 个瓶子位于位置 (xi,yi)。阿迪尔和贝拉每次各自最多只能携带一个瓶子。
对阿迪尔和贝拉而言,整个过程如下:
- 选择停止操作,或继续收集瓶子;
- 若选择继续,则挑选某个瓶子,并朝它走过去;
- 拾起该瓶子,并走向回收箱;
- 返回步骤 1。
阿迪尔和贝拉可以独立行动。他们可以同时拾取瓶子;所有瓶子均可由其中任意一人拾取;也允许其中一人静止不动,而另一人继续拾取瓶子。
他们希望安排整个过程,使得两人行走的总距离(即阿迪尔行走距离与贝拉行走距离之和)尽可能小。当然,最终所有瓶子都必须被放入回收箱中。
输入格式
First line of the input contains six integers a__x, a__y, b__x, b__y, t__x and t__y (0 ≤ a__x, a__y, b__x, b__y, t__x, t__y ≤ 109) — initial positions of Adil, Bera and recycling bin respectively.
The second line contains a single integer n (1 ≤ n ≤ 100 000) — the number of bottles on the ground.
Then follow n lines, each of them contains two integers x__i and y__i (0 ≤ x__i, y__i ≤ 109) — position of the i-th bottle.
It's guaranteed that positions of Adil, Bera, recycling bin and all bottles are distinct.
输入的第一行包含六个整数 ax、ay、bx、by、tx 和 ty(0 ≤ ax,ay,bx,by,tx,ty ≤ 109),分别表示 Adil、Bera 和回收箱的初始位置。
第二行包含一个整数 n(1 ≤ n ≤ 100000)—— 地面上瓶子的数量。
接下来是 n 行,每行包含两个整数 xi 和 yi(0 ≤ xi,yi ≤ 109)—— 第 i 个瓶子的位置。
保证 Adil、Bera、回收箱以及所有瓶子的位置互不相同。
输出格式
Print one real number — the minimum possible total distance Adil and Bera need to walk in order to put all bottles into recycling bin. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6.
Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct if
.
输出一个实数——Adil 和 Bera 为将所有瓶子放入回收箱所需行走的最小总距离。若你的答案的绝对或相对误差不超过 10−6,则视为正确。
即:假设你的答案为 a,评测组的答案为 b。当且仅当
时,评测程序将判定你的答案正确。
输入输出样例
输入#1
3 1 1 2 0 0 3 1 1 2 1 2 3
输出#1
11.084259940083
输入#2
5 0 4 2 2 0 5 5 2 3 0 5 5 3 5 3 3
输出#2
33.121375178000
说明/提示
Consider the first sample.
Adil will use the following path:
.
Bera will use the following path:
.
Adil's path will be
units long, while Bera's path will be
units long.
考虑第一个样例。
阿迪尔将采用以下路径:
。
贝拉将采用以下路径:
。
阿迪尔的路径长度为
个单位,而贝拉的路径长度为
个单位。
输入解题思路,AI测评打分。不知道怎么写?