AcWing 3601. 成绩排序
原题链接
简单
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const int N = 1e3+10;
int t,n,m,k,l,r,op,x,y;
string s[N];
struct nd{
int pos;
int age;
int sco;
};
nd ndd[N];
bool cmp(const nd&nd1,const nd&nd2){
if(nd1.sco==nd2.sco){
if(s[nd1.pos]==s[nd2.pos]){
return nd1.age<nd2.age;
}
return s[nd1.pos]<s[nd2.pos];
}
return nd1.sco<nd2.sco;
}
void solve(){
cin>>n;
for(int i = 1;i<=n;i++){
cin>>s[i]>>ndd[i].age>>ndd[i].sco;
ndd[i].pos = i;
}
sort(ndd+1,ndd+1+n,cmp);
for(int i = 1;i<=n;i++){
cout<<s[ndd[i].pos]<<" "<<ndd[i].age<<" "<<ndd[i].sco<<"\n";
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}