Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
3294 | 孙浚轩 | 奖学金 | C++ | Accepted | 0 MS | 268 KB | 670 | 2024-05-04 18:30:23 |
#include<bits/stdc++.h> using namespace std; struct score{ int id; int chi; int mat; int eng; int sum(){ return chi+mat+eng; }void input(){ cin>>chi>>mat>>eng; } }; bool cmp(score a,score b){ int a_all=a.sum(),b_all=b.sum(); if(a_all!=b_all) return a_all>b_all; else if(a.chi!=b.chi) return a.chi>b.chi; else return a.id<b.id; } int main(){ score stu[300]; int n; cin>>n; for(int i=1;i<=n;i++){ stu[i].input(); stu[i].id=i; } sort(stu+1,stu+n+1,cmp); for(int i=1;i<=5;i++) cout<<stu[i].id<<" "<<stu[i].sum()<<endl; return 0; }