P1093 [NOIP2007 普及组] 奖学金 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
const int N = 2e7+10,M = 1e3+10;
int a[N],pre[N];
int chi[N],math[N],eng[N],id[N],b[N];
struct student
{int id;int c,m,e;int sum;
};
bool cmp(student a,student b)
{if(a.sum>b.sum)return 1;else if(a.sum<b.sum)return 0;else{if(a.c>b.c)return 1;else if(a.c<b.c)return 0;else{if(a.id>b.id)return 0;else return 1;}}
}
signed main()
{std::ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);student stu[310];int n;cin>>n;for(int i=1;i<=n;i++){stu[i].id = i;cin>>stu[i].c>>stu[i].m>>stu[i].e;stu[i].sum=stu[i].c+stu[i].m+stu[i].e;}sort(stu+1,stu+1+n,cmp);for(int i=1;i<=5;i++){cout<<stu[i].id<<' '<<stu[i].sum<<endl;}return 0;
}