#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
最新推荐文章于 2021-02-20 19:09:19 发布