Codeforces Round #352 (Div. 2) C. Recycling Bottles
来源:互联网 发布:u盘安装centos双系统 编辑:程序博客网 时间:2024/06/05 18:29
/* ***********************************************Author :MaltubEmail :xiang578@foxmail.comBlog :htttp://www.xiang578.com************************************************ */#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <set>#include <map>#include <string>#include <math.h>#include <stdlib.h>#include <time.h>//#include <bits/stdc++.h>#define rep(i,a,n) for(int i=a;i<n;i++)#define per(i,a,n) for(int i=n-1;i>=a;i--)#define pb push_backusing namespace std;typedef vector<int> VI;typedef long long ll;const ll mod=1000000007;const int N=2048;struct node{ double s; int n;}tp;double dis(double a1,double b1,double a2,double b2){ double tmp=(a1-a2)*(a1-a2)+(b1-b2)*(b1-b2); return sqrt(tmp);}vector<node>pa;vector<node>pb;int main(){ //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int n; double tmp,a,b,ax,ay,bx,by,tx,ty,ans,t,ta,tb; scanf("%lf%lf%lf%lf%lf%lf",&ax,&ay,&bx,&by,&tx,&ty); scanf("%d",&n); tmp=0; pa.clear(); pb.clear(); for(int i=0;i<n;i++) { scanf("%lf%lf",&a,&b); t=dis(a,b,tx,ty); ta=dis(a,b,ax,ay); tb=dis(a,b,bx,by); tmp+=2*t; ta=ta-t; tb=tb-t; tp.n=i; tp.s=ta; if(pa.size()==0) pa.push_back(tp); else{ if(pa.size()==1) pa.push_back(tp); else if(pa[1].s>tp.s) swap(pa[1],tp); if(pa[0].s>pa[1].s) swap(pa[0],pa[1]); } tp.n=i; tp.s=tb; if(pb.size()==0) pb.push_back(tp); else{ if(pb.size()==1) pb.push_back(tp); else if(pb[1].s>tp.s) swap(pb[1],tp); if(pb[0].s>pb[1].s) swap(pb[0],pb[1]); } //printf("%lf %lf %lf\n",t,ta,tb); } //printf("%.10f\n",tmp); //printf("%lf %lf %lf %lf \n",pa[0].s,pa[1].s,pb[0].s,pb[1].s); if(pa[0].n==pb[0].n){ if(pb.size()==1&&pa.size()==1) { ans=tmp+min(pa[0].s,pb[0].s); //ans=min(ans,min(tmp+pa[0].s,tmp+pb[0].s)); } else { //printf("%lf %lf\n",pa[0].s+pb[1].s,pa[1].s+pb[0].s); ans=tmp+min(pa[0].s+pb[1].s,pa[1].s+pb[0].s); ans=min(ans,min(tmp+pa[0].s,tmp+pb[0].s)); } } else { ans=tmp+pa[0].s+pb[0].s; ans=min(ans,min(tmp+pa[0].s,tmp+pb[0].s)); } printf("%.12f\n",ans); return 0;}
0 0
- Codeforces 672 C. Recycling Bottles(Codeforces Round #352 (Div. 2))
- Codeforces Round #352 (Div. 2) C. Recycling Bottles
- Codeforces Round #352 (Div. 2) C - Recycling Bottles
- Codeforces Round #352 (Div. 2)C. Recycling Bottles
- Codeforces Round #352 (Div. 2) C. Recycling Bottles
- Codeforces Round #352 (Div. 2) C. Recycling Bottles
- Codeforces Round #352 (Div. 2) C. Recycling Bottles
- Codeforces Round #352 (Div. 2) C. Recycling Bottles (几何)
- Codeforces Round #352 (Div. 2) C. Recycling Bottles __ geometry, greedy and pretreat
- Codeforces Round #352 (Div. 1) A. Recycling Bottles
- Codeforces Round #352 (Div. 1) A. Recycling Bottles 暴力
- Codeforces #352 Recycling Bottles
- Codeforces #352 Div2 C Recycling Bottles
- codeforces#352-C - Recycling Bottles-贪心
- codeforces 672C. Recycling Bottles
- CodeForces-672C-Recycling Bottles
- codeforces 672C Recycling Bottles
- CodeForces Round 352——Recycling Bottles & Robin Hood
- ios htttp网络请求cookie的读取与写入(NSHTTPCookieStorage)
- 关于web service的几点认识
- iOS cookie
- SCU 4510 TaoSama与煎饼(dp)
- Installation failed due to invalid APK file!问题
- Codeforces Round #352 (Div. 2) C. Recycling Bottles
- 管道(无名管道)和FIFO(有名管道)
- iOS cookies
- java Thread学习-Thread的实现方法 继承Thread,实现Runnable 接口
- C++之剖析虚函数1——虚函数的设计目的
- ios htttp网络请求cookie的读取与写入(NSHTTPCookieStorage)
- 在VS2010中去掉ipch和sdf文件方法
- Android基础学习【历史流程重走】 ---- Sqlite数据库使用及ListView的使用与优化(三)
- Android应用内截屏