AcWing 3376. 成绩排序2
原题链接
简单
作者:
熵减E
,
2024-01-25 17:35:07
,
所有人可见
,
阅读 25
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
struct Student{
int number;
int score;
};
bool comp(Student lhs,Student rhs){
if(lhs.score < rhs.score) return true;
else if(lhs.score == rhs.score && lhs.number < rhs.number) return true;
else return false;
}
int main(){
int N,p,q;
scanf("%d",&N);
vector<Student> stu(N);
for(int i = 0 ; i < N; ++i){
scanf("%d%d",&stu[i].number,&stu[i].score);
}
sort(stu.begin(),stu.end(),comp);
for(int i = 0; i < N; ++i){
printf("%d %d\n",stu[i].number,stu[i].score);
}
return 0;
}