# 题目

100]内的整数。数字间以空格分隔。

14 60 80
10000001 64 90
10000002 90 60
10000011 85 80
10000003 85 80
10000004 80 85
10000005 82 77
10000006 83 76
10000007 90 78
10000008 75 79
10000009 59 90
10000010 88 45
10000012 80 100
10000013 90 99
10000014 66 60

12
10000013 90 99
10000012 80 100
10000003 85 80
10000011 85 80
10000004 80 85
10000007 90 78
10000006 83 76
10000005 82 77
10000002 90 60
10000014 66 60
10000008 75 79
10000001 64 90

# 解析

`from functools import cmp_to_key`

# 代码

## C++解法

```#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

const int maxn = 1e5 + 5;
int n, L, H;

struct Node {
int id, d, c;
Node() {}
Node(int _id, int _d, int _c) : id(_id), d(_d), c(_c) {}

static int getGrade(const Node stu) {
if (stu.d >= H && stu.c >= H)
return 4;
else if (stu.d >= H && stu.c < H)
return 3;
else if (stu.d < H && stu.c < H && stu.d >= stu.c)
return 2;
else
return 1;
}
bool operator<(const Node &rhs) const {
const Node stu1 = *this;
const Node stu2 = rhs;
int gstu1 = Node::getGrade(stu1);
int gstu2 = Node::getGrade(stu2);
int ret = 0;
if (gstu1 == gstu2)
if ((stu1.d + stu1.c) == (stu2.d + stu2.c))
if (stu1.d == stu2.d)
ret = stu2.id - stu1.id;
else
ret = stu1.d - stu2.d;
else
ret = (stu1.d + stu1.c) - (stu2.d + stu2.c);
else
ret = gstu1 - gstu2;
return ret > 0 ? true : false;
}
};

Node stus[maxn];
int main() {
cin.tie(0);
cin.sync_with_stdio(false);

cin >> n >> L >> H;

int m = 0;
for (int i = 0; i < n; ++i) {
int a, b, c;
cin >> a >> b >> c;
if (b >= L && c >= L)
stus[m++] = Node(a, b, c);
}

sort(stus, stus + m);

printf("%d\n", m);
for (int i = 0; i < m; ++i)
printf("%d %d %d\n", stus[i].id, stus[i].d, stus[i].c);

return 0;
}

```

## Python解法

```from functools import cmp_to_key
import re

def compare(stu1, stu2):
if stu[1] >= c and stu[2] >= c:
return 4
elif stu[1] >= c and stu[2] < c:
return 3
elif stu[1] < c and stu[2] < c and stu[1] >= stu[2]:
return 2
else:
return 1
ret = 0
if gstu1 == gstu2:
if (stu1[1] + stu1[2]) == (stu2[1] + stu2[2]):
if stu1[1] == stu2[1]:
ret = stu2[0] - stu1[0]
else:
ret = stu1[1] - stu2[1]
else:
ret = (stu1[1] + stu1[2]) - (stu2[1] + stu2[2])
else:
ret = gstu1 - gstu2
return ret

def inputInt():
return [int(i) for i in re.findall(r"[0-9]+",input())]

(a, b, c) = inputInt()
lst = []
for i in range(a):
stu = inputInt()
if stu[1] >= b and stu[2] >= b:
lst.append(stu)
lst.sort(key=cmp_to_key(compare), reverse=True)

print(len(lst))
for i in lst:
print(" ".join([str(j) for j in i]))
```