icebear233 @ 2024-08-12 09:58:02
感觉题解好麻烦,直接设几个变量在线处理就好了(这次应该不会被删了吧,没发题解也没发无关内容,如果违规评论区@我一下万分感谢QAQ)
#include<bits/stdc++.h>
using namespace std;
int n,now,y,maxn,shu,ying,ans1,ans2,ans3;string s,ans;
int main(){
cin>>n;
while(n--){
cin>>s>>y>>shu>>ying;
now=y+shu+ying;
if(now>maxn){
ans=s;
ans1=y;
ans2=shu;
ans3=ying;
maxn=now;
}
}
cout<<ans<<' '<<ans1<<' '<<ans2<<' '<<ans3;
return 0;
}
by simple_child @ 2024-08-12 09:59:37
@icebear233 你这代码#1WA啊
by AAAuc03 @ 2024-08-12 10:02:50
@icebear233 过不了,#1WA验证*2
by icebear233 @ 2024-08-12 10:05:37
@simple_child @AAAuc03 做的防抄,把特判给去了
by icebear233 @ 2024-08-12 10:05:59
害怕被紫菜
by sea_of_answers @ 2024-08-12 10:07:37
我也是这样写,但AC了
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,yu,shu,ying,maxi=-1e9,maxiyu,maxishu,maxiying;
string name,maxiname;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>name>>yu>>shu>>ying;
if(yu+shu+ying>maxi)
{
maxi=yu+shu+ying;
maxiname=name;
maxiyu=yu;
maxishu=shu;
maxiying=ying;
}
}
cout<<maxiname<<" "<<maxiyu<<" "<<maxishu<<" "<<maxiying;
}
by simple_child @ 2024-08-12 10:08:06
@icebear233 要是我的话把#1下载下来做特判(乐
by liuweilun2905 @ 2024-08-12 17:28:43
AC了