303466: CF671A. Recycling Bottles

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Recycling Bottles

题意翻译

Adil和Bera两个人在公园捡地上的瓶子放到垃圾桶里,公园可以视为一个二维平面,地上有$n$个瓶子,第$i$个瓶子的位置是$(x_i, y_i)$.Adil和Bera每个人一次只能携带一个瓶子 他们按照如下步骤捡瓶子: 1:决定停下或者继续捡瓶子 2:如果决定继续捡瓶子,则走向一个地上的瓶子 3:捡起这个瓶子,走向垃圾桶 4:回到步骤1 你可以任意安排Adil和Bera怎么捡瓶子(两个人捡的瓶子可能不一样多,甚至可能有一个人在原地没有捡瓶子),需要将所有的瓶子都捡到垃圾桶里,要求两人走的路程之和最小 输入: 第一行六个数$a_x, a_y, b_x, b_y, t_x, t_y(0<=a_x, a_y, b_x, b_y, t_x, t_y<=10^9)$,依次为Adil, Bera, 垃圾桶的初始坐标 第二行一个数$n(1<=n<=10^5)$,表示瓶子的个数 接下来$n$行,每行两个数$x_i, y_i(0<=x_i, y_i<=10^9)$,表示第$i$个瓶子的坐标 输出一个数,表示最小路程和(与答案的绝对误差或相对误差在$10^-6$以内即被视为正确)

题目描述

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: 1. Choose to stop or to continue to collect bottles. 2. If the choice was to continue then choose some bottle and walk towards it. 3. Pick this bottle and walk to the recycling bin. 4. 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.

输入输出格式

输入格式


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}<=10^{9} $ ) — initial positions of Adil, Bera and recycling bin respectively. The second line contains a single integer $ n $ ( $ 1<=n<=100000 $ ) — 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}<=10^{9} $ ) — position of the $ i $ -th bottle. It's guaranteed that positions of Adil, Bera, recycling bin and all bottles are distinct.

输出格式


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 ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF671A/c5d4f85807f95b08a3db7aae534822038a5bf1df.png).

输入输出样例

输入样例 #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: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF671A/9e150a5b7d96969b57a5b1f4dea00f000710a7e2.png). Bera will use the following path: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF671A/3884532a18b9773dea1f2047e6bbd80cd6d12185.png). Adil's path will be ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF671A/d2c02d2d4b61a9b8e78355ce9a7fbc852f71e66b.png) units long, while Bera's path will be ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF671A/da983b0763053dcb65ef9a22647e2063dd0571f6.png) units long.

Input

题意翻译

Adil和Bera两个人在公园捡地上的瓶子放到垃圾桶里,公园可以视为一个二维平面,地上有$n$个瓶子,第$i$个瓶子的位置是$(x_i, y_i)$.Adil和Bera每个人一次只能携带一个瓶子 他们按照如下步骤捡瓶子: 1:决定停下或者继续捡瓶子 2:如果决定继续捡瓶子,则走向一个地上的瓶子 3:捡起这个瓶子,走向垃圾桶 4:回到步骤1 你可以任意安排Adil和Bera怎么捡瓶子(两个人捡的瓶子可能不一样多,甚至可能有一个人在原地没有捡瓶子),需要将所有的瓶子都捡到垃圾桶里,要求两人走的路程之和最小 输入: 第一行六个数$a_x, a_y, b_x, b_y, t_x, t_y(0<=a_x, a_y, b_x, b_y, t_x, t_y<=10^9)$,依次为Adil, Bera, 垃圾桶的初始坐标 第二行一个数$n(1<=n<=10^5)$,表示瓶子的个数 接下来$n$行,每行两个数$x_i, y_i(0<=x_i, y_i<=10^9)$,表示第$i$个瓶子的坐标 输出一个数,表示最小路程和(与答案的绝对误差或相对误差在$10^-6$以内即被视为正确)

加入题单

算法标签: