POJ Election Time
来源:互联网 发布:幸运牛抽奖软件 编辑:程序博客网 时间:2024/05/12 07:42
Description
The cows are having their first election after overthrowing the tyrannical Farmer John, and Bessie is one of N cows (1 ≤ N ≤ 50,000) running for President. Before the election actually happens, however, Bessie wants to determine who has the best chance of winning.
The election consists of two rounds. In the first round, the K cows (1 ≤ K ≤ N) cows with the most votes advance to the second round. In the second round, the cow with the most votes becomes President.
Given that cow i expects to get Ai votes (1 ≤ Ai ≤ 1,000,000,000) in the first round and Bi votes (1 ≤ Bi ≤ 1,000,000,000) in the second round (if he or she makes it), determine which cow is expected to win the election. Happily for you, no vote count appears twice in the Ai list; likewise, no vote count appears twice in the Bi list.
Input
* Line 1: Two space-separated integers: N and K
* Lines 2..N+1: Line i+1 contains two space-separated integers: Ai and Bi
Output
* Line 1: The index of the cow that is expected to win the election.
Sample Input
5 33 109 25 68 46 5
Sample Output
5
题解
翻译在网上找,看得懂。两个sort就好。
#include<cstdio>#include<cstring>#include<cmath>#include<cstdlib>#include<iostream>#include<algorithm>using namespace std;int n,m;struct aaa {int x,y,w;} a[50002];bool kp1(const aaa &i,const aaa &j){return i.x>j.x;}bool kp2(const aaa &i,const aaa &j){return i.y>j.y;}int main(){scanf("%d%d",&n,&m);for(int i=1;i<=n;i++) {scanf("%d%d",&a[i].x,&a[i].y); a[i].w=i; }sort(a+1,a+n+1,kp1);sort(a+1,a+m+1,kp2);printf("%d\n",a[1].w);return 0;}
- poj 3664 Election Time
- POJ Election Time
- poj 3664 Election Time
- POJ 3664 Election Time
- POJ 3664----Election Time
- POJ 3664 Election Time
- POJ 3664 Election Time 题解
- POJ 3664 Election Time 再想想
- Election Time
- Election Time
- poj——3664——Election Time
- pku3664 Election Time
- BNUOJ 14362 Election Time
- POJ_3664 Election Time
- POJ3664 Election Time
- POJ3664——Election Time
- (Relax ST1.22)POJ 3664 Election Time(两次排序的巧妙应用)
- poj 2643 Election
- IT启程之路-csdn免积分下载方法
- 高清视频拼接设计方案
- 遍历文件夹中的文件
- MyEclipse 10.6 下载及破解
- cocos2dx 3.0正式版 分别在windows和mac上新建项目
- POJ Election Time
- 利用Apache服务器实现个人网页的访问
- MyEclipse10.0各个版本官网下载地址
- Ubuntu 开机报错解决方法
- 安装Django
- 一起来学UML(1)——UML建模工具Umbrello初体验
- Astar-baidu2014—1001 Energy Conversion
- 清明上河图邮票多少钱
- Android 4.0 framework源码修改编译,模拟器运行不起来