CodeForces - 672C Recycling Bottles (贪心)

CodeForces - 672C
Time Limit: 2000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u

Status

Description

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 (xi, yi). 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.

Input

First line of the input contains six integers ax, ay, bx, by, tx and ty (0 ≤ ax, ay, bx, by, tx, ty ≤ 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 xi and yi (0 ≤ xi, yi ≤ 109) — position of the i-th bottle.

It's guaranteed that positions of Adil, Bera, recycling bin and all bottles are distinct.

Output

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 .

Sample Input

Input
3 1 1 2 0 0
3
1 1
2 1
2 3
Output
11.084259940083
Input
5 0 4 2 2 0
5
5 2
3 0
5 5
3 5
3 3
Output
33.121375178000

Sample Output

Hint

Source

//题意:
两个人要将n个瓶子放到垃圾箱里,每个人每次只能拿一个瓶子,问他们走的最短的路是多长?
先输入A的坐标,B的坐标,垃圾箱的坐标,再输入一个n,表示马上又n个瓶子,然后是n个坐标。
//思路:
贪心&模拟,分四种情况,
1、A先取,B后取。
2、B先取,A后取
3、只有A取
4、只有B取
输出最短的就行了。
Hait:0x3f3f3f3f太小了,得重新定义。
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<iostream>
#define INF 1e30
#define N 100010
using namespace std;
struct zz
{
	double x;
	double y;
	double la;
	double lb;
	double lt;
}p[N];
int main()
{
	double ax,ay,bx,by,tx,ty;
	int n,i,j;
	while(scanf("%lf%lf%lf%lf%lf%lf",&ax,&ay,&bx,&by,&tx,&ty)!=EOF)
	{
		double len=INF;
		int m;
		scanf("%d",&n);
		for(i=0;i<n;i++)
		{
			scanf("%lf%lf",&p[i].x,&p[i].y);
			p[i].la=sqrt((p[i].x-ax)*(p[i].x-ax)+(p[i].y-ay)*(p[i].y-ay));
			p[i].lb=sqrt((p[i].x-bx)*(p[i].x-bx)+(p[i].y-by)*(p[i].y-by));
			p[i].lt=sqrt((p[i].x-tx)*(p[i].x-tx)+(p[i].y-ty)*(p[i].y-ty));
		}
		int ma=-1,mb=-1;
		double la=-INF,lb=-INF;
		for(i=0;i<n;i++)
		{
			if(p[i].lt-p[i].la>=la)
			{
				la=p[i].lt-p[i].la;
				ma=i;
			}
		}
		for(i=0;i<n;i++)
		{
			if(i==ma)
				continue;
			if(p[i].lt-p[i].lb>=lb)
			{
				lb=p[i].lt-p[i].lb;
				mb=i;
			}
		}
		double sum1=0;
		for(i=0;i<n;i++)
		{
			if(i==ma||i==mb)
				continue;
			sum1+=2*p[i].lt;
		}
		sum1+=p[ma].la+p[mb].lb+p[ma].lt+p[mb].lt;
		
		ma=-1;mb=-1;	
		lb=-INF;la=-INF;
		for(i=0;i<n;i++)
		{
			if(p[i].lt-p[i].lb>=lb)
			{
				lb=p[i].lt-p[i].lb;
				mb=i;
			}
		}
		for(i=0;i<n;i++)
		{
			if(i==mb)
				continue;
			if(p[i].lt-p[i].la>=la)
			{
				la=p[i].lt-p[i].la;
				ma=i;
			}
		}
		double sum2=0;
		for(i=0;i<n;i++)
		{
			if(i==ma||i==mb)
				continue;
			sum2+=2*p[i].lt;
		}
		sum2+=p[ma].la+p[mb].lb+p[ma].lt+p[mb].lt;
		
		ma=-1;la=-INF;
		double sum3=0;
		for(i=0;i<n;i++)
		{
			if(p[i].lt-p[i].la>=la)
			{
				la=p[i].lt-p[i].la;
				ma=i;
			}
		}
		for(i=0;i<n;i++)
		{
			if(i==ma)
				continue;
			sum3+=2*p[i].lt;
		}
		sum3+=p[ma].la+p[ma].lt;

		mb=-1;lb=-INF;
		double sum4=0;
		for(i=0;i<n;i++)
		{
			if(p[i].lt-p[i].lb>=lb)
			{
				lb=p[i].lt-p[i].lb;
				mb=i;
			}
		}
		for(i=0;i<n;i++)
		{
			if(i==mb)
				continue;
			sum4+=2*p[i].lt;
		}
		sum4+=p[mb].lb+p[mb].lt;

		printf("%.10lf\n",min(min(sum1,sum2),min(sum3,sum4)));
	}
	return 0;
} 


以下是对提供的参考资料的总结,按照要求结构化多个要点分条输出: 4G/5G无线网络优化与网规案例分析: NSA站点下终端掉4G问题:部分用户反馈NSA终端频繁掉4G,主要因终端主动发起SCGfail导致。分析显示,在信号较好的环境下,终端可能因节能、过热保护等原因主动释放连接。解决方案建议终端侧进行分析处理,尝试关闭节电开关等。 RSSI算法识别天馈遮挡:通过计算RSSI平均值及差值识别天馈遮挡,差值大于3dB则认定有遮挡。不同设备分组规则不同,如64T和32T。此方法可有效帮助现场人员识别因环境变化引起的网络问题。 5G 160M组网小区CA不生效:某5G站点开启100M+60M CA功能后,测试发现UE无法正常使用CA功能。问题原因在于CA频点集标识配置错误,修正后测试正常。 5G网络优化与策略: CCE映射方式优化:针对诺基亚站点覆盖农村区域,通过优化CCE资源映射方式(交织、非交织),提升RRC连接建立成功率和无线接通率。非交织方式相比交织方式有显著提升。 5G AAU两扇区组网:与三扇区组网相比,AAU两扇区组网在RSRP、SINR、下载速率和上传速率上表现不同,需根据具体场景选择适合的组网方式。 5G语音解决方案:包括沿用4G语音解决方案、EPS Fallback方案和VoNR方案。不同方案适用于不同的5G组网策略,如NSA和SA,并影响语音连续性和网络覆盖。 4G网络优化与资源利用: 4G室分设备利旧:面对4G网络投资压减与资源需求矛盾,提出利旧多维度调优策略,包括资源整合、统筹调配既有资源,以满足新增需求和提质增效。 宏站RRU设备1托N射灯:针对5G深度覆盖需求,研究使用宏站AAU结合1托N射灯方案,快速便捷地开通5G站点,提升深度覆盖能力。 基站与流程管理: 爱立信LTE基站邻区添加流程:未提供具体内容,但通常涉及邻区规划、参数配置、测试验证等步骤,以确保基站间顺畅切换和覆盖连续性。 网络规划与策略: 新高铁跨海大桥覆盖方案试点:虽未提供详细内容,但可推测涉及高铁跨海大桥区域的4G/5G网络覆盖规划,需考虑信号穿透、移动性管理、网络容量等因素。 总结: 提供的参考资料涵盖了4G/5G无线网络优化、网规案例分析、网络优化策略、资源利用、基站管理等多个方面。 通过具体案例分析,展示了无线网络优化中的常见问题及解决方案,如NSA终端掉4G、RSSI识别天馈遮挡、CA不生效等。 强调了5G网络优化与策略的重要性,包括CCE映射方式优化、5G语音解决方案、AAU扇区组网选择等。 提出了4G网络优化与资源利用的策略,如室分设备利旧、宏站RRU设备1托N射灯等。 基站与流程管理方面,提到了爱立信LTE基站邻区添加流程,但未给出具体细节。 新高铁跨海大桥覆盖方案试点展示了特殊场景下的网络规划需求。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值