60?

P1093 [NOIP2007 普及组] 奖学金

_Minmatar_Star @ 2020-06-23 21:57:43

60?

#include<iostream>
#include<algorithm>
using namespace std;
struct st{
    int a,b,c,d,id;
};
bool cmp(st a,st b){
    if(a.d>b.d)return 1;
    else if(a.d<b.d)return 0;
    else{
        if(a.a>b.a)return 1;
        else if(a.a<b.a)return 0;
        else{
            if(a.id<b.id)return 1;
            else return 0;
        }
    }
}
int main(){
    int n;
    cin>>n;
    st stu[n+1];
    for(int i=1;i<=n;i++){
        cin>>stu[i].a>>stu[i].b>>stu[i].c;
        stu[i].d=stu[i].a+stu[i].b+stu[i].c;
        stu[i].id=i;
    }
    sort(stu,stu+n+1,cmp);
    for(int i=0;i<5;i++){
        cout<<stu[i].id<<" "<<stu[i].d<<endl;
    }
    return 0;
}

by _Minmatar_Star @ 2020-06-23 21:58:56

为什么是60 呜呜呜


by Evolution957 @ 2020-12-21 22:37:20

@mini108346 把n+1改成305就可以AC了


|