现在的位置: 首页 > 综合 > 正文

poj 3664 Election Time

2013年07月09日 ⁄ 综合 ⁄ 共 429字 ⁄ 字号 评论关闭
#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");
}

抱歉!评论已关闭.