博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
POJ3664
阅读量:4682 次
发布时间:2019-06-09

本文共 1420 字,大约阅读时间需要 4 分钟。

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 
#include
#include
#include
#define maxn 20020using namespace std;struct node{ int a,b,num;}w[50010+10];bool cmp(node X,node Y){ return X.a>Y.a;}int main(){ int n,k; while(~scanf("%d%d",&n,&k)) { for(int i=0;i

转载于:https://www.cnblogs.com/--lr/p/6716101.html

你可能感兴趣的文章
linux积累
查看>>
预处理-03-文件包含、条件编译、小结
查看>>
Codeforces Round #417 (Div. 2) E. Sagheer and Apple Tree(树上Nim)
查看>>
Wannafly挑战赛1 C MMSet2
查看>>
sgu 197 Nice Patterns Strike Back
查看>>
Java的初步认识
查看>>
笔记:虚拟机类加载机制
查看>>
combobox中动态载入tree数据
查看>>
【课程12】循环嵌套和算法
查看>>
设计模式——外观模式
查看>>
mongodb 脚本操作
查看>>
基本运算符
查看>>
在MAC OS 下配置python + Flask ,并支持pyCharm编辑器
查看>>
解决:Invalid character found in method name. HTTP method names must be tokens
查看>>
Cracking the coding interview--Q1.8
查看>>
用c++写一个广告系统
查看>>
Atom编辑器入门到精通(一) 安装及使用基础
查看>>
jQuery插件开发(转)
查看>>
java中volatile不能保证线程安全
查看>>
Oracle左连接、右连接、全外连接以及(+)号用法
查看>>