只有90呀!红一个

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

S_mz @ 2024-05-25 16:12:11

#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,name;
    int sum=0,n,yu,shu,ying,a,b,c;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>name;
        cin>>yu>>shu>>ying;
        if(yu+shu+ying>sum){
            sum=yu+shu+ying;
            s=name;
            a=yu;
            b=shu;
            c=ying;
        }
    }
    cout<<s<<' '<<a<<' '<<b<<' '<<c;
    return 0;
}

by LinkQR @ 2024-05-25 16:18:01

@S_mz

总分有可能为0

hack:

1
dingjunwei 0 0 0

sum=0 -> sum=-1


by S_mz @ 2024-05-25 16:36:05

谢谢看不懂


by gravityma @ 2024-06-06 21:08:05

是#1错了吗


|