Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
23910 | LeoWang | 病人排队 | C++ | Accepted | 1 MS | 244 KB | 614 | 2023-08-01 23:51:48 |
#include<bits/stdc++.h> using namespace std; struct Patient{ string id; int age,num; }; bool cmp(Patient a,Patient b){ if(a.age>=60&&b.age<60){ return a.age>b.age; } else if(a.age>=60&&b.age>=60){ if(a.age!=b.age) return a.age>b.age; else return a.num<b.num; } else if(a.age<60&&b.age<60){ return a.num<b.num; } else if(a.age<60&&b.age>=60){ return a.age>b.age; } } int main(){ int n; cin>>n; Patient p[n]; for(int i=0;i<n;i++){ cin>>p[i].id>>p[i].age; p[i].num=i; } sort(p,p+n,cmp); for(int i=0;i<5;i++){ cout<<p[i].id<<endl; } return 0; }