POJ3664

来源:互联网 发布:java驻场开发怎么样 编辑:程序博客网 时间:2024/05/16 16:04
//知道为什么几次提交都是WA了,原来是struct没有初始化,对于任何程序,细节决定成败#include<iostream>#include<algorithm>using namespace std;#define SIZE 50010struct vote{vote(): a(0),b(0),num(0){};int a;int b;int num;};int cmp1(vote t1,vote t2){return t1.a>t2.a;}int cmp2(vote t1,vote t2){return t1.b>t2.b;}int main(){vote cow[SIZE];int m,n;cin>>m>>n;for(int i=0;i<m;++i){cin>>cow[i].a>>cow[i].b;cow[i].num=i+1;}sort(cow,cow+m,cmp1);sort(cow,cow+n,cmp2);cout<<cow[0].num<<endl;return 0;}

原创粉丝点击