一、题目
二、代码
分析:
题目不是很难,关键在于排序
按照题目分成四个列表,代表四类考生,然后分别对列表里的考生按照规则排序即可
关于排序可以借助 列表的 sort 方法
具体可参考:[sort 方法详解](https://blog.csdn.net/nanhuaibeian/article/details
/99656250)
注意:
感觉代码已经够简洁了,用内置函数完全可以解决,但是还是存在两个测试点没有超时,郁闷,翻看博客,应该是 python 的性能所致
N, L, H = map(int, input().split())
num1 = []
num2 = []
num3 = []
num4 = []
def printf(num):
if num:
for i in num:
print("%d %d %d" % (i[0], i[1], i[2]))
for i in range(N):
temp = list(map(int, input().split()))
if temp[1] >= L and temp[2] >= L:
if temp[1] >= H and temp[2] >= H:
num1.append(temp)
elif temp[1] >= H and temp[2] < H:
num2.append(temp)
elif temp[1] >= temp[2]:
num3.append(temp)
else:
num4.append(temp)
num1.sort(key=lambda x:(-(x[1]+x[2]),-x[1],x[0]))
num2.sort(key=lambda x:(-(x[1]+x[2]),-x[1],x[0]))
num3.sort(key=lambda x:(-(x[1]+x[2]),-x[1],x[0]))
num4.sort(key=lambda x:(-(x[1]+x[2]),-x[1],x[0]))
print(len(num1) + len(num2) + len(num3) + len(num4))
printf(num1)
printf(num2)
printf(num3)
printf(num4)