2021-10-18 20:44
西南大学 Python 牛客98348831...:名字重复也能用字典: while True: try: num = int(input()) n = int(input()) dic = {} for i in range(num): person = input().split() if int(person[1]) in dic: dic[int(person[1])].append(person[0]) else: dic[int(person[1])] = [person[0]] if n == 0: for i in sorted(dic,reverse=True): for j in dic[i]: print(j + ' ' + str(i)) else: for i in sorted(dic): for j in dic[i]: print(j + ' ' + str(i)) except: break
0 点赞 评论 收藏
分享
创作者周榜
更多
关注他的用户也关注了: