提交时间:2024-08-21 16:38:09
运行 ID: 180623
#include<bits/stdc++.h> using namespace std; struct stu{ int id, ch, en, ma; int total; }s[305]; bool cmp(stu s1,stu s2){ if(s1.total != s2.total) return s1.total > s2.total; if(s1.ch != s2.ch) return s1.ch > s2.ch; return s1.id < s2.id; } int n; int main(){ cin >> n; for(int i = 1; i <= n; i++){ cin >> s[i].ch >> s[i].ma >> s[i].en; s[i].id = i; s[i].total = s[i].ch + s[i].ma + s[i].en; } for(int i = 1; i < n;i++){ for(int j = 1; j < n - i + 1; j++){ if(!cmp(s[j],s[j+1])) swap(s[j],s[j+1]); } } for(int i = 1; i <= 5; i++){ cout << s[i].id << " " << s[i].total << endl; } return 0; }