'commit'
This commit is contained in:
42
GESP/Level5/Eratosthenes/new
Normal file
42
GESP/Level5/Eratosthenes/new
Normal file
@@ -0,0 +1,42 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int N = 10010;
|
||||
struct Node {
|
||||
int id; // 第几个学生
|
||||
int c, m, e; // 语文 数学 英语
|
||||
friend bool operator<(Node a, Node b) {
|
||||
int s1 = a.c + a.m + a.e;
|
||||
int s2 = b.c + b.m + b.e; // 总分
|
||||
if (s1 != s2) // 总分不同 总分大的在前
|
||||
return s1 > s2;
|
||||
if (a.c + a.m != b.c + b.m) // 语文和数学总分不同 语文和数学总分大的在前
|
||||
return a.c + a.m > b.c + b.m;
|
||||
|
||||
if (max(a.c, a.m) != max(b.c, b.m)) // 语文和数学中较大的一个不同 较大的在前
|
||||
return max(a.c, a.m) > max(b.c, b.m);
|
||||
return a.id < b.id; // 语文和数学中较大的一个相同 录入顺序小的在前
|
||||
}
|
||||
} a[N];
|
||||
int main() {
|
||||
int n;
|
||||
cin >> n;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> a[i].c >> a[i].m >> a[i].e; // 同学的语文、数学、外语成绩
|
||||
a[i].id = i; // 同学的录入顺序
|
||||
}
|
||||
sort(a + 1, a + n + 1);
|
||||
|
||||
// 5 3 2 4 1
|
||||
// 100 100 98 98 97
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
// 到a数组中去查找
|
||||
for (int j = 1; j <= n; j++) {
|
||||
if (a[j].id == i) {
|
||||
cout << j << endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user