80求调

P1093 [NOIP2007 普及组] 奖学金

dys0711 @ 2024-11-03 22:14:56

#include<bits/stdc++.h>
using namespace std;

struct app{
    int x,c,m,e,z;
}ap[302];

bool emp(app a,app b){
    if(a.z>b.z){
        return a.z>b.z;
    }
    else if(a.z==b.z){
        if(a.c>b.c){
            return a.c>b.c;
        }
        else if(a.c==b.c){
            return a.x<b.x;
        }
    }
    else {
        return a.z>b.z;
    } 

}

int main(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d %d %d",&ap[i].c,&ap[i].m,&ap[i].e);
        ap[i].z=ap[i].c+ap[i].m+ap[i].e;
        ap[i].x=i;
    }
    sort(ap+1,ap+n+1,emp);
    for(int i=1;i<=5;i++){
        printf("%d %d\n",ap[i].x,ap[i].z);
    }
    return 0;
}

感激不尽


|