//P5740 【深基7.例9】最厉害的学生
//#define LOCAL
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
#include <sstream>
#define inf 0x3f3f3f3f
#define eps 1e-6
using namespace std;
#define clr(x) memset(x,0,sizeof((x)))
const int maxn = 1e5+1;//2e6+1
#define MAX(a,b,c) ((a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c)))
#define _max(a,b) ((a) > (b) ? (a) : (b))
#define _min(a,b) ((a) < (b) ? (a) : (b))
#define _for(a,b,c) for(int a = b;a<c;a++)
typedef struct student
{
char name[10];
int a,b,c,tot;
}stu;
/*
int cmp(const void* a,const void* b) {
stu *s1 = (stu*)a;
stu *s2 = (stu*)b;
return (s1->tot) < (s2->tot);//从大到小
}
*/
bool cmp1( stu a, stu b) {
return a.tot > b.tot;//从大到小
}
int main()
{
#ifdef LOCAL
freopen("data.in","r",stdin);
freopen("data.out","w",stdout);
#endif
int n;
stu s[1005];
cin>>n;
for(int i = 0;i<n;i++) {
scanf("%s%d%d%d",s[i].name,&s[i].a,&s[i].b,&s[i].c);
s[i].tot = s[i].a+s[i].b+s[i].c;
}
// qsort(s,n,sizeof(stu),cmp);
sort(s,s+n,cmp1);
printf("%s %d %d %d",s[0].name,s[0].a,s[0].b,s[0].c);
return 0;
}
洛谷 P5740 【深基7.例9】最厉害的学生 题解 C/C++
最新推荐文章于 2024-07-26 21:41:04 发布