PAT乙级-1015 德才论

 

 解题代码(部分运行超时):

##输入
admission_list = list(map(int,input().rstrip().split()))
allstudent_list =[]
for i in range(admission_list[0]):
    allstudent_list.append(list(map(int,input().rstrip().split())))

##分类
#优先录取
beststu_list = []
#德胜才
twostu_list = []
#德才兼亡
threestu_list = []
#过线
fourstu_list = []
#真正第四类
truefoustu_list = []

for i in range(len(allstudent_list)):
    if allstudent_list[i][1] >= admission_list[1] and allstudent_list[i][2] >= admission_list[1]:
        fourstu_list.append(allstudent_list[i])

admission_len = len(fourstu_list)

for i in range(len(fourstu_list)):
    if fourstu_list[i][1] >= admission_list[2] and fourstu_list[i][2] >= admission_list[2]:
        beststu_list.append(fourstu_list[i])
    elif fourstu_list[i][1] >= admission_list[2] and fourstu_list[i][2] < admission_list[2]:
        twostu_list.append(fourstu_list[i])
    elif fourstu_list[i][1] < admission_list[2] and fourstu_list[i][2] < admission_list[2] and fourstu_list[i][1] >= fourstu_list[i][2]:
        threestu_list.append(fourstu_list[i])
    else:
        truefoustu_list.append(fourstu_list[i])


def sortstu(stu_list):
    for i in range(len(stu_list)):
        for j in range(0,len(stu_list)-i-1):
            if stu_list[j][1] + stu_list[j][2] < stu_list[j+1][1] + stu_list[j+1][2]:
                stu_list[j],stu_list[j+1] = stu_list[j+1],stu_list[j]
            elif stu_list[j][1] + stu_list[j][2] == stu_list[j+1][1] + stu_list[j+1][2] and stu_list[j][1] < stu_list[j+1][1]:
                stu_list[j],stu_list[j+1] = stu_list[j+1],stu_list[j]
            elif stu_list[j][1] + stu_list[j][2] == stu_list[j+1][1] + stu_list[j+1][2] and stu_list[j][1] == stu_list[j+1][1] and stu_list[j][0] > stu_list[j+1][0]:
                stu_list[j],stu_list[j+1] = stu_list[j+1],stu_list[j]
if len(beststu_list) > 1:
    sortstu(beststu_list)
if len(twostu_list) > 1:
    sortstu(twostu_list)
if len(threestu_list) > 1:
    sortstu(threestu_list)
if len(truefoustu_list) > 1:
    sortstu(truefoustu_list)

all_student = beststu_list + twostu_list + threestu_list + truefoustu_list


print(admission_len)
for i in all_student:
    for j in range(len(i)):
        if j == len(i) - 1:
            print(i[j])
        else:
            print(i[j],end = ' ')

        
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值