POJ 3664 Election Time
来源:互联网 发布:java过滤器和拦截器 编辑:程序博客网 时间:2024/05/16 13:37
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
#include <stdio.h>#include <algorithm>using namespace std;typedef __int64 ll;const int maxn=50000+10;struct pp{ll first,second;int id;}s[maxn];int cmp1(const pp &x,const pp &y){return x.first>y.first;}int cmp2(const pp &x,const pp &y){return x.second>y.second;}int main(){int n,k,i,j,ans;scanf("%d%d",&n,&k);for(i=0;i<n;i++){scanf("%I64d%I64d",&s[i].first,&s[i].second);s[i].id=i+1;}sort(s,s+n,cmp1);sort(s,s+k,cmp2);//注意第二次是前k个printf("%d\n",s[0].id);return 0;}
- poj 3664 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 再想想
- POJ Election Time
- poj——3664——Election Time
- Election Time
- Election Time
- (Relax ST1.22)POJ 3664 Election Time(两次排序的巧妙应用)
- pku3664 Election Time
- BNUOJ 14362 Election Time
- POJ_3664 Election Time
- POJ3664 Election Time
- POJ3664——Election Time
- poj 2643 Election
- 界面编程中的MVC模式
- ASP.Net MVC 生成安全验证码
- 求1+2+3+...+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)
- 第五周 项目四 静态成员应用
- 第六周项目二我的数组类
- POJ 3664 Election Time
- ACM——1029
- 取代MDK的神器--COIDE
- 模板讲解
- 锋利的JQuery 第三章内容
- iOS-------------主題管家
- ACM——1236
- 【C++】虚函数
- 设计模式之抽象工程模式Abstract Factory Pattern()C++实现