提交时间:2025-05-10 14:00:59

运行 ID: 321447

#include<bits/stdc++.h> using namespace std; struct sgh{ string id; int age; int t; }p[110]; bool cmp(sgh x,sgh y){ if(x.age>=60&&y.age>=60){ if(x.age!=y.age){ return x.age>y.age; } return x.t<y.t; } if(x.age<60&&y.age<60){ return x.t<y.t; } return x.age>y.age; } int main(){ int n; cin>>n; for(int i=1;i<=n;i++){ cin>>p[i].id>>p[i].age; p[i].t=i; } sort(p+1,p+n+1,cmp); for(int i=1;i<=n;i++){ cout<<p[i].id<<endl; } return 0; }