wczxluo @ 2023-08-04 20:34:21
#include<bits/stdc++.h>
using namespace std;
struct qwe{
char b[10001];
int q,w,e,t,u;
}a[100001];
bool comp(qwe x,qwe y)
{
return x.t>y.t;
if(x.t==x.t)
return x.u<x.u;
}
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i].b>>a[i].e>>a[i].q>>a[i].w;
a[i].t=a[i].e+a[i].q+a[i].w;
a[i].u=i;
}
sort(a+1,a+1+n,comp);
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n-i;j++)
{
if(a[i].t==a[j+1].t)
swap(a[j].u,a[j+1].u);
}
}
cout<<a[1].b<<" "<<a[1].e<<" "<<a[1].q<<" "<<a[1].w;
}
by dingzj2022 @ 2023-08-04 20:43:11
@wczxluo 参考一下:
#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 wczxluo @ 2023-08-04 20:52:01
@dingzj2022 Thank you
by dingzj2022 @ 2023-08-04 20:53:18
@wczxluo 给个关?
by wczxluo @ 2023-08-04 20:53:40
@dingzj2022 ok
by dingzj2022 @ 2023-08-04 20:55:32
@wczxluo 谢谢