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.
30 lines
725 B
30 lines
725 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
const int N = 310;
|
|
int n;
|
|
struct Student {
|
|
int id, chinese, total;
|
|
} a[N];
|
|
|
|
bool cmp(const Student &a, const Student &b) {
|
|
if (a.total == b.total) {
|
|
if (a.chinese == b.chinese) return a.id < b.id;
|
|
else return a.chinese > b.chinese;
|
|
} else
|
|
return a.total > b.total;
|
|
}
|
|
|
|
int main() {
|
|
cin >> n;
|
|
for (int i = 0; i < n; i++) {
|
|
int math, english;
|
|
cin >> a[i].chinese >> math >> english;
|
|
a[i].total = a[i].chinese + math + english;
|
|
a[i].id = i + 1;
|
|
}
|
|
sort(a, a + n, cmp);
|
|
for (int i = 0; i < 5; i++)
|
|
cout << a[i].id << " " << a[i].total << endl;
|
|
return 0;
|
|
} |