poj 3664

简介: http://poj.org/problem?id=3664 进行两轮选举,第一轮选前n进入第二轮,第二轮选最高   #include #include using namespace std; struct vote { int a,b; int c; ...

 

http://poj.org/problem?id=3664

进行两轮选举,第一轮选前n进入第二轮,第二轮选最高

 

#include<algorithm>
#include<cstdio>
using namespace std;
struct vote
{
    int a,b;
    int c;
};
bool cmp1(const vote  & a ,const vote & b)
{
    return a.a>b.a;
}

bool cmp( const vote& a ,const vote& b)
{
    return a.b>b.b;
}
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    vote aa[50010];
        for(int i=0;i<n;i++)
        {
            aa[i].c=0;
            scanf("%d%d",&aa[i].a,&aa[i].b);
            aa[i].c=i+1;
        }
        sort(aa,aa+n,cmp1);
        sort(aa,aa+k,cmp);


   printf("%d\n",aa[0].c);
    return 0;
}

 

相关文章
|
9月前
|
算法
Highways(POJ—2485)
Highways(POJ—2485)
|
9月前
Hopscotch(POJ-3050)
Hopscotch(POJ-3050)
|
9月前
|
算法 数据建模
Poj 3169(差分约束系统)
Poj 3169(差分约束系统)
39 0
|
存储
POJ 2262 Goldbach&#39;s Conjecture
Problem Description In 1742, Christian Goldbach, a German amateur mathematician, sent a letter to Leonhard Euler in which he made the foll...
1024 0
|
机器学习/深度学习 算法
|
机器学习/深度学习