九度oj 题目1346:会员积分排序

http://ac.jobdu.com/problem.php?id=1346 

View Code
 1 #include<iostream>
2 #include<cstring>
3 #include<algorithm>
4 #include<cmath>
5 using namespace std;
6 typedef struct node
7 {
8 int id,score;
9 };
10 node a[1008];
11 int n,m;
12 bool cmp(const node &a,const node &b)
13 {
14 if(a.score==b.score) return a.id<b.id;
15 else return a.score>b.score;
16 }
17 int main()
18 {
19 while(cin>>n>>m)
20 {
21 int i;
22 for(i=0;i<n;i++) cin>>a[i].id>>a[i].score;
23 sort(a,a+n,cmp);
24 int len=min(m,n);
25 for(i=0;i<len;i++) cout<<a[i].id<<endl;
26 }
27 return 0;
28 }


 

posted @ 2012-03-28 16:00  keepmoving89  阅读(172)  评论(0编辑  收藏  举报