poj 3664 Election Time

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

struct Info{
       int index, fv, sv;
}info[50001];

bool cmp1(Info a, Info b)
{
     return a.fv > b.fv;
}

bool cmp2(Info a, Info b)
{
     return a.sv > b.sv;
}

int main()
{
    int i, j, n, k;
    while (scanf("%d%d", &n, &k) != EOF){
           for (i = 0; i < n; i++){
                scanf("%d%d", &info[i].fv, &info[i].sv);
                info[i].index = i+1;
           }
           sort(info, info+n, cmp1);//第一次排序找出前三的 
           sort(info, info+k, cmp2);//第二次排序找出第一名 
           cout << info[0].index << endl;
    }
    
    system("pause");
}



   

你可能感兴趣的:(poj 3664 Election Time)