WA 20分求助

P5740 【深基7.例9】最厉害的学生

programmer330 @ 2024-10-13 16:11:25

#include<bits/stdc++.h>
using namespace std;
struct student{
    string name;
    int ch,ma,en;
    int total;
};
student a[10001];
int n;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i].name>>a[i].ch>>a[i].ma>>a[i].en;
        a[i].total=a[i].ch+a[i].ma+a[i].en;
    }
    long long max=1;

    for(int j=2;j<=n;j++){
        if(a[1].total>=a[2].total) max=1;
        else{
            if(a[j].total>=a[j-1].total) max=j;
        }

    }
    cout<<a[max].name<<" "<<a[max].ch<<" "<<a[max].ma<<" "<<a[max].en;

    return 0;
}

|