90求助(之前写的,改了三次,懵了)

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

zhang_dian @ 2023-08-16 15:51:49


using namespace std;
string name[1005];
int yu[1005],shu[1005],ying[1005];
int main()
{
    int n,max=0,id;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>name[i]>>yu[i]>>shu[i]>>ying[i];
    }
    for(int i=1;i<=n;i++)
    {
        if(yu[i]+shu[i]+ying[i]>max)
        {
            max=yu[i]+shu[i]+ying[i];
            id=i;
        }
    }
    cout<<name[id]<<" "<<yu[id]<<" "<<shu[id]<<" "<<ying[id];
    return 0;
}```

by zk_y @ 2023-08-16 16:06:16

就是有一些长


by zhang_dian @ 2023-08-16 16:07:06

谢谢谢谢,各位,AC了(芜湖~~)


by zhang_dian @ 2023-08-16 16:08:38

@zhangkeyuan0623 谢谢您,关注了,感谢


by zhang_dian @ 2023-08-16 16:09:44

@C202301 谢谢,懂了,谢谢您


by C202301 @ 2023-08-16 16:19:58

对,有一个很讨厌的测试点


by NC2023guoxiao @ 2023-08-26 17:35:46

#include<bits/stdc++.h>
#include<string>
#include<iomanip> 
using namespace std;
typedef struct {
    string name;
    long long c_sc;
    long long m_sc;
    long long e_sc;
} stu;
int main() {
    long long n;
    cin>>n;
    const long long len=n+5;
    stu s[len];
    long long bi=0,sc_s[len]={-1000000};
    for(int i=1;i<=n;i++) {
        cin>>s[i].name>>s[i].c_sc>>s[i].m_sc>>s[i].e_sc;
        sc_s[i]=s[i].c_sc+s[i].m_sc+s[i].e_sc;
        if(sc_s[i]>sc_s[bi]) bi=i;
    }
    cout<<s[bi].name<<" "<<s[bi].c_sc<<" "<<s[bi].m_sc<<" "<<s[bi].e_sc;
    return 0;
}

这是正确代码↑


上一页 |