Time Limit: 3.0 Seconds Memory Limit: 65536K Total Runs: 866 Accepted Runs: 455 Multiple test files
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< <