You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
790 B

2 years ago
#include <bits/stdc++.h>
using namespace std;
const int N = 310;
struct Person {
int chinese, math, english;
int total;
int id;
const bool operator<(const Person &b) const {
if (total != b.total) return total > b.total;
if (chinese != b.chinese) return chinese > b.chinese;
return id < b.id;
}
} person[N];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
int chinese, math, english;
cin >> chinese >> math >> english;
int total = chinese + math + english;
person[i] = {chinese, math, english, total, i + 1};
}
sort(person, person + n);
// 有5名
for (int i = 0; i < 5; i++) printf("%d %d\n", person[i].id, person[i].total);
return 0;
}