XXC114514 @ 2024-07-16 10:54:59
#include <bits/stdc++.h>
using namespace std;
struct student {
string name;
int c, m, e;
int total;
};
student a[50000];
int n;
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i].name >> a[i].c >> a[i].m >> a[i].e;
a[i].total = a[i].c + a[i].m + a[i].e;
}
for (int i = n - 1; i > 0; i--) {
for (int j = 0; j < i; j++) {
if (a[j].total > a[j + 1].total) {
swap(a[j], a[j + 1]);
}
}
cout << a[i].name << ' ' << a[i].c << ' ' << a[i].m << ' ' << a[i].e;
break;
}
}
by zml1029 @ 2024-07-30 12:33:27
#include<cstdio>
#include<iostream>
using namespace std;
string name[1005];
int cg[1005],mg[1005],eg[1005];
int main(){
int n,max=-999999,t;
scanf("%d",&n);
for(int a=0;a<n;a++)cin>>name[a]>>cg[a]>>mg[a]>>eg[a];
for(int b=0;b<n;b++){
if(cg[b]+mg[b]+eg[b]>max){
max=cg[b]+mg[b]+eg[b];
t=b;
}
}
cout<<name[t]<<" "<<cg[t]<<" "<<mg[t]<<" "<<eg[t];
return 0;
}