0
已解决
赵孟喆
资深守护
资深守护
ke.codingtang.com/#/problem/problemSub?id=2732
- #include<iostream> #include<algorithm>
- using namespace std;
- struct stu{
- string s;
- int y,m,d;
- int id;
- int sum(){
- return y+m+d;
- }
- }
- a[305];
- bool
- cmp(stu x,stu q){
- if(x.sum()!=q.sum()){
- return x.sum()>q.sum();
- }
- else if(x.y!=q.y){
- return x.y>q.y;
- }
- return x.id<q.id;
- }
- int main(){
- int n;
- cin>>n;
- for(int i=1;i<=n;i++){
- cin>>a[i].s>>a[i].y>>a[i].m>>a[i].d; a[i].id=i;
- }
- sort(a+1,a+n+1,cmp);
- cout<<a[1].id<<" "<<a[1].sum()<<endl; cout<<a[2].id<<" "<<a[2].sum()<<endl; cout<<a[3].id<<" "<<a[3].sum()<<endl; cout<<a[4].id<<" "<<a[4].sum()<<endl; cout<<a[5].id<<" "<<a[5].sum()<<endl; return 0; }