Codeforces 671A Recycling Bottles

Quartus Prime 软件 USB-blaster 驱动安装失败【已解决】 一、安装步骤 1、将FPGA 开发板插入电脑时,未安装驱动的电脑会提示安装usb-Blaster驱动。Windows搜索框打开设备管理器,在“其他设备”下会发现黄色感叹号的“USB-Blaster”的设备驱动。 2、Quartus系列软件的安装目录下自带USB-blaster的驱动程序,右键更新驱动,选择驱动目录:(D:\intelFPGA\18.1\quartus\drivers\usb-blaster,文件位置和版本请按照自己安装的路径选择),点击Next开始安装。 3、安装成功,重启电脑即可使 阅读详情

题目

C. Recycling Bottles
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
     outputstandard output
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:

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.

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 .

Examples

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

Note

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.

题意

有两个人A,B在一个二维平面上捡瓶子放到垃圾箱里,每个人从从初始位置出发,一次只能选择一个瓶子去捡,然后去垃圾箱,再去捡瓶子。。。也可以中途不捡了,给出A,B,垃圾箱和n个瓶子的坐标,求两个人捡完瓶子要的最短距离。

解法

设dis[0][i]表示A点到第i个瓶子的距离,dis[1][i]表示B点到第i个瓶子的距离,dis[2][i]表示垃圾箱到第i个瓶子的距离,sum表示sigam(2*dis[2][i])(1<=i<=n),如果A去的第一个点是PA,B去的第一个点是PB,那答案是sum-(2*dis[2][PA]-dis[0][PA]-dis[2][PA])-(2*dis[2][PB]-dis[1][PB]-dis[2][PB]),其中(1<=PA<=n,1<=PB<=n,PA!=PB),因为sum是定值,所以只要让后面两项加起来最大,可以先在数组dis[0]中找到最大的dis[0][i],然后在数组dis[1]中找到最大的dis[1][j]而且i!=j,然后相反的再来一次取最大的,还有一个如果某个是负数可以不选但不能两个都不选。

代码

#include<cstdio>
#include<cmath>
struct point
{
	double x,y;
}p[100005],A,B,bin;
int n;
double dis[3][100005];//dis[0][i]表示A点到第i个瓶子的距离,dis[1][i]表示B点到第i个瓶子的距离,dis[2][i]表示垃圾箱到第i个瓶子的距离
double Dis(point a,point b)
{
	return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
double max(double a,double b)
{
	return a>b?a:b;
}
int f(int f,int k)//在dis[f]中找一个i!=k且dis[f][i]最大
{
	int i,pos,flag=0;
	double ma;
	for(i=1;i<=n;i++)
	{
		if(i==k)
			continue;
		if(flag==0)
		{
			ma=dis[f][i];
			pos=i;
			flag=1;
		}
		else
		{
			if(dis[f][i]>ma)
			{
				ma=dis[f][i];
				pos=i;
			}
		}
	}
	return pos;
}
int main()
{
	int i,j;
	scanf("%lf%lf%lf%lf%lf%lf",&A.x,&A.y,&B.x,&B.y,&bin.x,&bin.y);
	scanf("%d",&n);
	double sum=0;
	for(i=1;i<=n;i++)
	{
		scanf("%lf%lf",&p[i].x,&p[i].y);
		dis[2][i]=Dis(p[i],bin);
		sum+=dis[2][i]*2;
	}
	for(i=1;i<=n;i++)
	{
		dis[0][i]=dis[2][i]-Dis(p[i],A);
		dis[1][i]=dis[2][i]-Dis(p[i],B);
	}
	int pos[3],flag=1;
	double ans;
	for(i=0;i<2;i++)
		for(j=0;j<2;j++)
		{
			if(i==j)
				continue;
			pos[i]=f(i,-1);
			pos[j]=f(j,pos[i]);
			double tmp;
			if(dis[j][pos[j]]<0)
				tmp=dis[i][pos[i]];
			else
				tmp=dis[i][pos[i]]+dis[j][pos[j]];
			if(flag)
			{
				ans=tmp;
				flag=0;
			}
			else
				ans=max(ans,tmp);
		}
	printf("%.8lf\n",sum-ans);
	return 0;
}


高通平台Android 无线 UWB 开发全解析:UWB系统设计、天线与校准全流程指南 为使 UWB 系统达到目标性能,在整个开发流程中遵循一套设计最佳实践至关重要。系统架构:需基于飞行时间(ToF)功能的基准方案(POR)定义系统框图,这是整体系统架构的基础。天线布局:天线位置对性能影响极大,需尽可能贴近 UWB 芯片,以减少信号损耗、保持高传输效率。器件选型:需谨慎选择元器件,推荐使用单刀双掷(SPDT)或双刀双掷(DPDT)开关、UWB 带通滤波器射频同轴测试接头,以保障信号传输路径与测试能力。原理图优化:原理图开发阶段,走线损耗优化极为关键。 阅读详情

相关推荐

指导初学者使用Anaconda运行GitHub上One - DM项目的步骤

指导初学者使用Anaconda运行GitHub上One - DM项目的步骤。

AI的内部世界的博客 1493

Codeforces 671A Recycling Bottles 【dp】

题目链接:Codeforces 672C Recycling Bottles C. Recycling Bottles time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output It was recycling day in Keko

世界很大 521

视频编解码——视频编解码器工作原理

目录什么是视频编解码器为什么需要视屏编解码器视频编码器与数字视频容器时评编码器的历史 什么是视频编解码器 简单来说就是用于压缩或解压数字视频的软件或硬件 编码是信息从一种形式或格式转换为另一种形式的过程,解码是编码的反向。 适用于视频 编码是将视频、音频的原始格式的文件通过压缩技术转换成另一种格式(视频如h.264,h.265,m-jpeg等)。 解码是编码的反向过程。应用中,一般是将h.264,h.265格式数据解码成如YUV格式裸流交给显示器显示。 为什么需要视屏编解码器 需要在有限的带宽或存储空间

路人coder 1万+

A. Recycling Bottles(坐标距离和转化)

https://codeforces.com/problemset/problem/671/A 题目描述 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 coordin

代码笔记本 286

基于OpenMV与双舵机云台的激光追踪系统实战解析

本文详细解析了基于OpenMV摄像头与双舵机云台的激光追踪系统设计与实现。从硬件选型、图像识别算法到PID控制逻辑,全面介绍了如何构建一个高效稳定的激光追踪系统,并分享了电子设计竞赛中的实战经验与调试技巧。该系统在智能玩具、安防监控及教学演示等领域具有广泛应用前景。

prometheus9mon的博客 272

SD - WAN:企业出海的网络加速器

例如,一家中国的跨境电商企业,在欧美市场的促销活动期间,借助 SD - WAN 技术,即使面对海量订单数据的交互,也能确保欧美客户在浏览商品、下单支付时感受到近乎本地网络的流畅体验,大大提升了客户满意度,稳住了销售增速。企业无需在海外本地部署大量冗余服务器,只需依托云台,借助 SD - WAN 快速稳定的网络连接,即可轻松实现业务拓展,进一步精简运营架构,提升整体效能。在未来,随着技术的不断演进和企业出海需求的持续增长,SD - WAN 将持续赋能,助力更多企业在全球市场扬帆远航,书写辉煌篇章。

idcicp_com的博客 455

codeforces 671A

题意:给你两个人的位置和一个箱子的位置,然后给出n个瓶子的位置,要求让至少一个人去捡瓶子放到箱子里面去,一次只能拿一个瓶子,求把全部瓶子捡完之后的距离总和最小 思路:仔细想想,如果一个人去捡了某个瓶子那么他之后肯定会走到箱子的位置上去,然后再去捡的话就是箱子到某个瓶子的距离,那么我们可以分这样三种情况考虑,人物A一个人捡完了所有的瓶子,人物B一个人捡完了所有瓶子,人物A捡了某个瓶子  人物B捡了

傻傻分不清、 441

2025年华为杯中国研究生数学建模竞赛A题 通用神经网络处理器下的核内调度问题 思路+代码

针对通用神经网络处理器下的核内调度问题,我们提出了一套基于分层优化框架的系统性解决方案。该方案首先通过缓存敏感的启发式拓扑排序算法生成最小峰值缓存占用的调度序列,在满足计算图依赖关系的前提下优先选择能够释放或减少缓存占用的节点;随后采用最佳适应算法进行精细化的缓存分配,结合LRU换出策略动态管理多级缓存空间,最小化额外数据搬运量;最后引入多目标遗传算法进行联合优化,在严格控制数据搬运量不显著增加的前提下,通过关键路径分析、流水线并行和数据预取等技术进一步优化总执行时间。

YOLO 794

C. Recycling Bottles (几何)

题目链接:http://codeforces.com/contest/672/problem/C 题意:有两个人,a 和 b ,一个垃圾桶 t,给你他们在二维平面的坐标,和n个空瓶子的坐标,a和b要把这些垃圾放进垃圾桶。保证所有坐标不重合,问a和b总的最小行走距离。 算法:几何 思路:分为三种情况 a和b一定都参与——disl 只有a参与————disa 只有b参与————disb ...

凝望的博客 347

基于MATLAB的导弹轨迹和撞击位置仿真

本文将介绍如何使用MATLAB进行导弹轨迹和撞击位置的仿真,提高导弹的精确打击能力。首先,我们需要确定导弹的初始位置和速度,以及导弹所受到的外部环境因素如重力、空气阻力等。在MATLAB中,可以通过ODE求解器来模拟导弹的运动轨迹。最后,我们通过控制器输出的控制信号来控制导弹的姿态。通过对导弹的运动轨迹和姿态进行仿真,可以更好地预测和规划导弹的运动轨迹,提高其精确打击能力。在实际作战中,为了提高导弹精确打击能力,需要对导弹的撞击位置进行预测和规划。我们可以通过控制导弹的姿态来实现撞击目标的精确命中。

CyberLynxO的博客 1994

【PointNet++】制作点云数据集使用CloudCompare进行标注

使用PointNet++复现成功后,需要训练自己的数据集。于是使用cloudcompare参照ShapeNet的数据集格式去制作,最终保存的txt文件格式为“xyz+rgb+label”,一共7列。 自己按此制作好的数据集已成功训练及推测,于是记录下来让好兄弟好姐妹们少踩坑多吃肉。

纵马踏花向自由 5722

Codeforces Round #352 (Div. 1) A. Recycling Bottles

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 coordi

WZJRJ28 420

redhawk:Low Power Analysis

1.rush current与switch cell 在standby状态下为了控制leakage power我们选择power gating的设计方式,使用power switch cell关闭block/power domain的电源。 power switch的基本介绍可见: 低功耗设计-Power Switch power switch的table中有四种状态,对应block工作、待机和上电,下电。low power analysis主要分析上电的过程。 上电过程可以看做mos电容

m0_61544122的博客 3233

【模拟】Codeforces 671A Recycling Bottles

题目链接:   http://codeforces.com/problemset/problem/671/A 题目大意:   A和B在一张二维平面上,平面上有N个垃圾,垃圾桶只有一个在T,问把所有垃圾全扔进垃圾桶最少走多远。一次只能拿一个垃圾。允许一个人走另一个人停下来。   (1 ≤ n ≤ 100 000)(0 ≤ xi, yi ≤ 109) 题目思路:   【模拟...

PHILIP0917的博客 120

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

codeforces 671A Recycling Bottles

A. Recycling Bottles time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output It was recycling day in Kekoland. To c

EventQueue的博客 693

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

CodeForces 671A Recycling Bottles

A. Recycling Bottles time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output It was recycling day in Kekoland. To c

Calm微笑 457

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

Codeforces 671A Recycling Bottles(贪心+思维)

题目链接:http://codeforces.com/problemset/problem/671/A 题目大意:给你两个人的位置和一个箱子的位置,然后给出n个瓶子的位置,要求让至少一个人去捡瓶子放到箱子里面去,一次只能拿一个瓶子,求把全部瓶子捡完之后的距离总和最小。解题思路:开始有两个起点A,B。除了从A或B出发拿瓶子并回到箱子距离不确定,其他时候肯定要从箱子到瓶子再回到箱子,距离就...

weixin_30654583的博客 137

训练3.22(C: Recyling Bottles)

cf 671A 题目:http://codeforces.com/problemset/problem/671/A 题意:有A,B两人在捡瓶子。共有n个瓶子,回收箱只有一个,,记作 t 。给出A,B,n个瓶子以及回收箱的坐标位置,求捡完所有垃圾后两人所走过的最短路程。 且,捡瓶子有一定规则:要么不捡,要么直接走直线去捡,捡了之后也必须走直线直接去回收箱。 题解:假设人从决定去捡瓶子k开始到把瓶子k...

urp 156

Codeforces Round #352 (Div. 1) A. Recycling Bottles 暴力

A. Recycling Bottles 题目连接: http://www.codeforces.com/contest/671/problem/A Description It was recycling day in Kekoland. To celebrate it Adil and Bera went to Central Perk where they can take bottles ...

weixin_30878361的博客 67

codeforces 672C Recycling Bottles (枚举+贪心)

codeforces 672C Recycling Bottles (枚举+贪心)

Tc的专栏 1676

CF 672C 两个人捡瓶子 最短路与次短路思想

C. Recycling Bottles time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output It was recycling day in Kekoland. To c...

weixin_30765475的博客 176

codeforces 352 div 2 C.Recycling Bottles 贪心

C. Recycling Bottles time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output It was recycling day in Kekoland. To celebrate...

weixin_30443075的博客 151

CF671A Recycling Bottles 计算几何

CF671A Recycling Bottles 计算几何 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 in...

loooooog的博客 243

【codeforces 672 C】【计算几何+贪心】Recycling Bottles【有两个人和一个垃圾桶,n个瓶子,把每个瓶子捡起来然后扔到垃圾箱中,每人最多带一个瓶子,求最短总距离】

传送门:http://codeforces.com/contest/672/problem/C 题意:有两个人和一个垃圾桶,n个瓶子, 现在要人去把每个瓶子捡起来然后扔到垃圾箱中,每人最多带一个瓶子,求最短总距离 思路: 我先用坐标平移使得垃圾桶作为零点建立坐标系 假设人都在垃圾箱上,那么总距离为2 * 每个瓶子到垃圾桶的距离 现在人不在上面,所以只要求出瓶子到垃圾桶的距离 -

魔笛手的博客 746
上一篇: UVA 11825 Hackers' Crackdown
下一篇: 求节点数为n的AVL树的种数
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址