#include <bits/stdc++.h>
#define int long long //(有超时风险)
#define PII pair<int,int>
#define endl '\n'
#define LL __int128
using namespace std;
const int N=2e5+10,M=1e3+10,mod=998244353,INF=0x3f3f3f3f;
int a[N],pre[N];
//Node 是表示这个就是结构体,stu表示结构体数组的名字,
struct Node{
string name;
int chinese,math,eng,sum;
int idx;
}stu[N];
//比较函数,先按成绩排序,再按照先后排序
bool cmp(Node a,Node b)
{
if(a.sum!=b.sum)
{
return a.sum>b.sum;
}
else if(a.idx!=b.idx)
{
return a.idx<b.idx;
}
}
signed main()
{
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n;cin>>n;
for(int i=1;i<=n;i++)
{
string s;cin>>s;
int x,y,z;cin>>x>>y>>z;
stu[i]={s,x,y,z,x+y+z,i};
}
//按照题目要求排序
sort(stu+1,stu+n+1,cmp);
//第一个就是最大的
cout<<stu[1].name<<' '<<stu[1].chinese<<' '
<<stu[1].math<<' '<<stu[1].eng;
return 0;
}
P5740 【深基7.例9】最厉害的学生
最新推荐文章于 2024-05-20 15:29:54 发布