博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
c++心得00010- sort part2 的应用(额,还是单独写出来吧。。。2333)
阅读量:5061 次
发布时间:2019-06-12

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

2934.   
Election Time

Time Limit: 3.0 Seconds   
Memory Limit: 65536K
Total Runs: 866   
Accepted Runs: 455    
Multiple test files

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

 

Input details

There are 5 cows, 3 of which will advance to the second round. The cows expect to get 3, 9, 5, 8, and 6 votes, respectively, in the first round and 10, 2, 6, 4, and 5 votes, respectively, in the second.

 

Output details

Cows 2, 4, and 5 advance to the second round; cow 5 gets 5 votes in the second round, winning the election.

 

母鸡表示我们造反并独立了,要选个总统。

输入的2列理,第一列是round1的每个鸡的票数。第二列是round2的每个鸡的票数(only if 它晋级了,所以其实不是很科学啊,你都不知道它会不会晋级怎么就有票数了呢?对吧)

那么反正就sort吧。

#include 
#include
using namespace std;struct goddamncow{ int r1; int r2; int index;};int ca(goddamncow a,goddamncow b){ return a.r1
>m>>n; for(int i=0;i
>fa[i].r1>>fa[i].r2; fa[i].index=i+1; } sort(fa,fa+m,ca); sort(fa+m-n,fa+m,cb); cout<
<

转载于:https://www.cnblogs.com/stigmj/archive/2012/05/13/2497945.html

你可能感兴趣的文章
java操作二叉树
查看>>
Properties
查看>>
Java_I/O输入输出_实现读取文件时出现一个表示读取进度的进度条。可以使用java.swing包提供的输入流类ProgressMonitorInputStream...
查看>>
Linux Running State Process ".so"、"code" Injection Technology
查看>>
php学习笔记
查看>>
AJAX的使用
查看>>
在Windows 8.1及IE 11中如何使用HttpWatch
查看>>
时间仍在,是我们在飞逝
查看>>
[转]数据挖掘中所需的概率论与数理统计知识、上
查看>>
centos一键安装lnmp成功后无法访问ip(解决办法)
查看>>
在JS中使用全局变量
查看>>
Django学习-4-request获取数据
查看>>
python----redis
查看>>
证明:37的500次方减去37的100次方的结果是10的倍数!
查看>>
android 自定义流布局实现
查看>>
rzsz的安装
查看>>
批处理常见疑问
查看>>
枚举数与可枚举类型(笔记)
查看>>
marquee标签使用【转载】
查看>>
3.1 查找文本
查看>>