哪位大佬看一下,蒟蒻样例都过,只有90,qwq.

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

wcop114514 @ 2023-07-10 13:20:11

#include<bits/stdc++.h>
using namespace std;
int jj(int a,int b,int c){
    return a+b+c;
}
int main()
{
    int n,a,b,c,max=0,x,y,z;
    cin>>n;
    string s,d;
    for(int i=1;i<=n;i++){
        cin>>s>>a>>b>>c;
        if(jj(a,b,c)>max){
            max=jj(a,b,c);
            x=a;y=b;z=c;d=s;
        }
    } 
    cout<<d<<' '<<x<<' '<<y<<' '<<z;
    return 0;
}

by wcop114514 @ 2023-07-10 13:21:39

第一个测试点错了qwq


by Terry2011 @ 2023-07-10 13:22:01

#include<bits/stdc++.h>
using namespace std;
int main(){

    int n;
    cin>>n;
    string s,ss;
    int a,b,c,l=-1000,m=0,ad=0,bd=0,cd=0;
    for(int i=1;i<=n;i++){
        m=0;
        cin>>s>>a>>b>>c;
        m=a+b+c;
        if(m>l){
            l=m;
            ss=s;
            ad=a;
            bd=b;
            cd=c;
        }
    }
    cout<<ss<<" "<<ad<<" "<<bd<<" "<<cd;
    return 0;
}

by Terry2011 @ 2023-07-10 13:22:20

@wcop114514


by wcop114514 @ 2023-07-10 13:23:45

@Terry2011 谢谢


by Robbie9 @ 2023-08-02 10:54:29

@wcop114514

max初始值定义应该为0以下的数

你的名字好臭啊


|