10 条题解
-
1
#include <iostream> #include <algorithm> using namespace std; struct Student{ short chinese=0,math=0,english=0,number=0; int sum(){ return chinese+math+english; }; }; bool cmp(Student a,Student b){ if(a.sum()>b.sum()) return true; else if(a.sum()==b.sum()&&a.chinese>b.chinese) return true; else if(a.sum()==b.sum()&&a.chinese==b.chinese&&a.number<b.number) return true; else return false; } Student mxx[301]; int main(){ ios::sync_with_stdio(false); int n; cin >> n; for (int i = 1;i<=n;i++){ cin >> mxx[i].chinese >> mxx[i].math >> mxx[i].english; mxx[i].number = i; } sort(mxx+1,mxx+n+1,cmp); for (int i = 1;i<=5;i++){ cout << mxx[i].number << " " << mxx[i].sum() /*mxx[i].sum()*/ << endl; } }
信息
- ID
- 691
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 6
- 标签
- 递交数
- 594
- 已通过
- 203
- 上传者