题解 | #成绩排序#

成绩排序

https://www.nowcoder.com/practice/8e400fd9905747e4acc2aeed7240978b

import sys

n, order = int(input()), input()
dic = dict()
for i in range(n):
    inf = input().split(' ')
    dic[inf[0] + str(i).zfill(3)] = int(inf[1])

if order == '0':
    for i in sorted(dic.items(), key = lambda x : x[1], reverse = True):
        print(i[0][:-3] + ' ' + str(i[1]))
else:
     for i in sorted(dic.items(), key = lambda x : x[1]):
        print(i[0][:-3] +' ' + str(i[1]))





全部评论

相关推荐

点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务