题解 | #成绩排序#

成绩排序

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]))





全部评论

相关推荐

2025-12-15 11:27
门头沟学院 Java
哇哇的菜鸡oc:所有人不要理会,就好了,后面他就知道怎么回事了,只能说有的时候市场都是被宰的人搞坏的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务