排序+中位数 Vijos P2871 安装服务器
来源:互联网 发布:2017linux系统推荐 编辑:程序博客网 时间:2024/06/07 07:14
开始复习一些奇奇怪怪的东西了!!
顺道一提,所谓可以不在城市上完全就是假的!!瓜皮!!!这个完全可以自己画个一维的数轴证明一下。
/*嗯。。。。仔细一想发现这个距离的计算方法弄得这个二维的题目明显变成了两个一维的带权中位数嘛。。横轴:你在纵轴上面走跟我有什么关系咩? */
#include<iostream>#include<cstdio>#include<cstring>#include<cstdlib>#include<algorithm>#include<cmath>#include<set>#include<map>#include<vector>#include<queue>#include<cctype>#include<ctime>using namespace std;const int maxn=100005;int N,tot,ansx,ansy;struct info{ int x,y,v; }A[maxn];bool cmp1(info a,info b) { return a.x < b.x; }bool cmp2(info a,info b) { return a.y < b.y; }int main(){freopen("test.in","r",stdin);freopen("test.out","w",stdout);scanf("%d",&N);int x,y,k,p;for(int i = 1; i <= N; i++){scanf("%d%d%d%d",&x,&y,&k,&p);A[i] = (info){x,y,k*p};tot += k*p;}tot = (tot+1) / 2;sort(A+1,A+N+1,cmp1);int tmp = 0;for(int i = 1; i <= N; i++){tmp += A[i].v;if(tmp >= tot) { ansx = A[i].x; break; }}sort(A+1,A+N+1,cmp2);tmp = 0;for(int i = 1; i <= N; i++){tmp += A[i].v;if(tmp >= tot) { ansy = A[i].y; break; }}printf("%d %d",ansx,ansy);return 0;}
阅读全文
0 0
- 排序+中位数 Vijos P2871 安装服务器
- Vijos P1691 输油管道问题【中位数+排序】
- Vijos 1036题:安装服务器
- 【带权中位数】安装服务器
- Vijos 1549题:中位数
- Vijos 1691-输油管道问题【中位数】
- Vijos P1549 中位数(CQOI2009)题解
- 【带权中位数】安装服务器(server.pas/c/cpp)
- Vijos P1398 奖学金【排序】
- 二排序数组中位数
- 二排序数组中位数
- poj2388排序中位数
- 不排序求中位数
- poj1723 排序+中位数
- POJ1723 SOLDIERS【中位数+排序】
- HDU3194 Median【中位数+排序】
- VIJOS 1605 双栈排序
- 【vijos】【拓扑排序】拓扑编号
- 基于spring注解方式配置和使用spring AOP
- spring aop原理
- PHP常用函数总结(180多个)
- 银行卡验证接口API(仅需一行代码,实现全国银行卡核验)
- Intellij idea 非Maven项目导出War包
- 排序+中位数 Vijos P2871 安装服务器
- openCSV读写CSV文件
- 【剑指Offer】面试题39:二叉树的深度
- YAML最最基础语法
- soapui中文操作手册(一)----创建一个新的项目
- 继承结构中每个子类单独一张表
- js 递归
- HDU2089:不要62 数位dp
- Python入门基础知识总结