1015

def sort_student(students):
    i = 0
    j = 1
    student = {}
    for student in students:
        pass
    while j < len(students):
        i = 0
        while i < len(students) - j:
            s = students[i]
            t = students[i+1]
            if s['sum_f'] < t['sum_f']:
                student = students[i]
                students[i] = students[i+1]
                students[i+1] = student
            elif (students[i]['sum_f'] == students[i+1]['sum_f']) and (students[i]['d_f'] < students[i+1]['d_f']):
                    student = students[i]
                    students[i] = students[i+1]
                    students[i+1] = student
            elif (students[i]['sum_f'] == students[i+1]['sum_f'])and (students[i]['d_f'] == students[i+1]['d_f']) and (students[i]['number'] > students[i+1]['number']):
                    student = students[i]
                    students[i] = students[i+1]
                    students[i+1] = student
            i += 1
        j += 1
def printf(students):
    for student in students:
        print(student['number'], end = ' ')
        print(student['d_f'], end = ' ')
        print(student['c_f'])

def Printf(student_0):
    if len(student_0) > 0:
        sort_student(student_0)
        printf(student_0)
n, L, H = map(int, input().split())
students = []
students_both = []
student_2 = []
student_3 = []
student_4 = []
for number in range(1,n+1):
    number, d_f, c_f = input().split()
    d_f = int(d_f)
    c_f = int(c_f)
    number = int(number)
    student = {'number': number,
               'd_f': d_f,
               'c_f': c_f,
               'sum_f': d_f + c_f}
    students.append(student)
i = 0
num = 0
while i < n:
    student = students[i]
    if student['c_f'] >= L and student['d_f'] >= L:
        num += 1
        if student['c_f'] >= H and student['d_f'] >= H:
            students_both.append(student)
        elif student['c_f'] < H and student['d_f'] >= H:
            student_2.append(student)
        elif student['c_f'] < H and student['d_f'] < H and student['d_f'] >= student['c_f']:
                student_3.append(student)
        else:
            student_4.append(student)
    i += 1
print(num)
Printf(students_both)
Printf(student_2)
Printf(student_3)
Printf(student_4)
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值