提交时间:2025-04-26 14:58:09
运行 ID: 319431
#include<bits/stdc++.h> using namespace std; struct sa{ string s; int age,id; }a[105]; bool cmp(sa x,sa y){ if(x.age>=60&&y.age>=60){ if(x.age!=y.age){ return x.age>y.age; } return x.id>y.id; } if(x.age<60&&y.age<60){ return x.id>y.id; } return x.age>y.age; } int main(){ int n,k; cin>>n>>k; for(int i=0;i<=n;i++){ cin>>a[i].s>>a[i].age; a[i].id=i; } sort(a+1,a+n+1,cmp); for(int i=1;i<=n;i++){ cout<<a[i].s<<endl; } return 0; }