SGU114
来源:互联网 发布:部署ipv6网络 pdf 编辑:程序博客网 时间:2024/05/17 06:28
若干城市在一条线上,在这条线上建个转播站,定义城市的不高兴值为城市到转播站的距离*城市人数
给定城市坐标和人数,求最小的不高兴值
如果去掉城市人口就是个很裸很裸的求中位数
因为人口 当时卡了一会儿,实际上可以把它当做若干点是同一坐标,那么也就是一样的求中位数
sort一下就可以了
//Lib#include<cstdio>#include<cstring>#include<cstdlib>#include<cmath>#include<ctime>#include<iostream>#include<algorithm>#include<vector>#include<string>#include<queue>using namespace std;//Macro#define rep(i,a,b) for(int i=a,tt=b;i<=tt;++i)#define rrep(i,a,b) for(int i=a,tt=b;i>=tt;--i)#define erep(i,e,x) for(int i=x;i;i=e[i].next)#define irep(i,x) for(__typedef(x.begin()) i=x.begin();i!=x.end();i++)#define read() (strtol(ipos,&ipos,10))#define sqr(x) ((x)*(x))#define pb push_back#define PS system("pause");typedef long long ll;typedef pair<int,int> pii;const int oo=~0U>>1;const double inf=1e20;const double eps=1e-6;string name="",in=".in",out=".out";//Varpair<double,int> node[15008];int n,p,tot,pos;double k;void Work(){scanf("%d",&n);rep(i,1,n){scanf("%lf%d",&k,&p);node[i].first=k;node[i].second=p;tot+=p;}sort(node+1,node+1+n);tot=tot+1>>1;pos=1;while(tot>0&&pos<=n)tot-=node[pos].second,pos++;printf("%.5lf\n",node[pos-1].first);}int main(){//freopen((name+in).c_str(),"r",stdin);//freopen((name+out).c_str(),"w",stdout);//Init();Work();return 0;}
- SGU114
- sgu114
- sgu114
- SGU114 Telecasting station 三分
- SGU114-Telecasting station
- SGU114 水题 Easy Problem
- sgu114 Telecasting station 三分
- sgu114:Telecasting station
- SGU 水题集合2 SGU112 SGU113 SGU114 SGU115
- HDMI/DVI 显示器热插拔与检测原理(HPD)
- 十个顶级的C语言资源助你成为优秀的程序员
- 3个著名加密算法(MD5、RSA、DES)的解析
- CDHtmlDialog探索----Javascript与窗体交互
- World文档中所有的表格边框突然没有了,怎么办?
- SGU114
- arm linux oops 的定位方法(转)
- 在Apache服务器上基于不同IP地址架设两个WEB网站
- 网络图片下载并压缩保存
- 课堂笔记!
- JDBC连接Access数据库验证登录
- GridView数据导出到Excel中
- 获取客户端的真实IP地址
- 大流量、高并发网站验证码解决方案