题解
2023-08-15 17:01:13
发布于:广东
0阅读
0回复
0点赞
#include <iostream>
#include <algorithm>
using namespace std;
struct stu{
int score;
int num;
int cn;
};
stu a[300];
int n,ch,ma,en;
bool cmp(stu a,stu b){
if (a.score==b.score){
if (a.cn==b.cn) return a.num<b.num;
return a.cn>b.cn;
}
return a.score>b.score;
}
int main(){
cin >> n;
for (int i=1;i<=n;i++){
cin >> ch >> ma >> en;
a[i].num=i;
a[i].score=ch+ma+en;
a[i].cn=ch;
}
sort(a+1,a+n+1,cmp);
for (int i=1;i<=5;i++) cout << a[i].num << " " << a[i].score << "\n";
}
这里空空如也
有帮助,赞一个