Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
59515 | 李思睿 | 奖学金 | C++ | Accepted | 1 MS | 272 KB | 802 | 2023-10-29 13:58:38 |
#include<iostream> using namespace std; int n; struct Stu{ int chinese,math,english; int id; int sum; }stu[305]; bool cmp(Stu a,Stu b){ if(a.sum<b.sum){ return true; }else{ if(a.sum==b.sum){ if(a.chinese<b.chinese){ return true; }else{ if(a.chinese==b.chinese){ return a.id>b.id; }else{ return false; } } }else{ return false; } } } int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>stu[i].chinese>>stu[i].math>>stu[i].english; stu[i].sum=stu[i].chinese+stu[i].math+stu[i].english; stu[i].id=i; } for(int i=1;i<=n-1;i++){ for(int j=1;j<=n;j++){ if(cmp(stu[j],stu[j+1])){ swap(stu[j],stu[j+1]); } } } for(int i=1;i<=5;i++){ cout<<stu[i].id<<" "<<stu[i].sum<<endl; } return 0; }