60分求助大佬

P1093 [NOIP2007 普及组] 奖学金

ZKD_sy @ 2018-09-23 11:32:23

#include<cstdio>
#include<algorithm>
using namespace std;
const int N = 400;
int tot;
struct node{
    int s;
    int b;
    int c;
    int id;
}a[N];

bool cmp(node x , node y){
    if(x.s + x.b + x.c != y.s + y.b + y.c) 
        return x.s + x.b + x.c > y.s + y.b + y.c;
    else if(x.s != x.b) return x.s > x.b;
    else return x.id < y.id;
}

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1 ; i <= n ; i++){
        scanf("%d %d %d",&a[i].s , &a[i].b , &a[i].c);
        a[i].id = i;    
    }
    sort(a + 1 , a + n + 1 , cmp);
    for(int i = 1 ; i <= 5 ; i++){
        tot = a[i].s + a[i].b + a[i].c;
        printf("%d %d",a[i].id , tot);
        printf("\n");
    }
    return 0;
}

by ZKD_sy @ 2018-09-23 11:35:17

哦,没事了,自己zz了


by ZKD_sy @ 2018-09-23 11:38:10

论静态查错的重要性...


|