题解
2024-08-05 08:57:03
发布于:浙江
0阅读
0回复
0点赞
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
struct node{
int id,globalscore,chinese,math,english;
}a[310];
bool cmp(node x,node y){
if(x.globalscorey.globalscore){
if(x.chinesey.chinese)return x.id<y.id;
else return x.chinese>y.chinese;
}
else return x.globalscore>y.globalscore;
}
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
a[i].id=i;
cin>>a[i].chinese>>a[i].math>>a[i].english;
a[i].globalscore=a[i].chinese+a[i].math+a[i].english;
}sort(a+1,a+n+1,cmp);
for(int i=1;i<=5;i++){
cout<<a[i].id<<' '<<a[i].globalscore<<endl;
}
return 0;
}
这里空空如也
有帮助,赞一个