这道题,根据题意就很容易写出来了,因为先比第一轮,所以先排序第一轮,然后选出K个之后再在K个里面找票数最多的就OK了;
#include<bits/stdc++.h>
using namespace std;
struct Cow{
int first,second;
int index;//注意这里需要标记下标,因为sort排序会乱
}c[50010];
bool cmp(Cow a,Cow b){
return a.first>b.first;
}
int main(){
int n,k;
cin>>n>>k;
for(int i=1;i<=n;i++)
{
cin>>c[i].first>>c[i].second;
c[i].index=i;
}
sort(c+1,c+n+1,cmp);
int Max=0,b;
for(int i=1;i<=k;i++){
if(c[i].second>Max){
Max=c[i].second;
b=c[i].index;
}
}
printf("%d\n",b);
return 0;
}