'commit'
This commit is contained in:
35
TangDou/CSP-J/AcWingTraining/T2/429.cpp
Normal file
35
TangDou/CSP-J/AcWingTraining/T2/429.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
const int N = 310;
|
||||
|
||||
struct Person {
|
||||
int chinese, math, english;
|
||||
int total;
|
||||
int id;
|
||||
} person[N];
|
||||
|
||||
bool cmp(Person a, Person b) {
|
||||
if (a.total != b.total)
|
||||
return a.total > b.total;
|
||||
if (a.chinese != b.chinese)
|
||||
return a.chinese > b.chinese;
|
||||
|
||||
return a.id < b.id;
|
||||
}
|
||||
|
||||
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, cmp);
|
||||
// 有5名
|
||||
for (int i = 0; i < 5; i++) printf("%d %d\n", person[i].id, person[i].total);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user