90分,Q_W_Q

P1093 [NOIP2007 普及组] 奖学金

DKsniper @ 2024-01-24 10:21:00

#include<bits/stdc++.h>
using namespace std;
int n;
struct l{
    int c,m,e,xh,zf;
}a[310];
int cmp(l x,l y){
    if(x.zf!=y.zf) return x.zf>y.zf;
    else{
        if(x.c!=y.c) return x.c>y.c;
        return x.xh>y.xh;
    }
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i].c>>a[i].m>>a[i].e;
        a[i].zf=a[i].c+a[i].e+a[i].m;
        a[i].xh=i;
    }
    sort(a+1,a+1+n,cmp);
    for(int i=1;i<=5;++i) cout<<a[i].xh<<" "<<a[i].zf<<endl;
    return 0; 
}

by oldhorse1989 @ 2024-01-24 10:36:14

@DKsniper 学号小的在前


by DKsniper @ 2024-01-24 10:38:44

@oldhorse1989

谢谢,已经A了


|