BSF level
获赞
845
粉丝
10
关注
4
看过 TA
123
西南大学
2014
Python
IP属地:北京
暂未填写个人简介
私信
关注
2021-10-18 20:44
西南大学 Python
while True: try: n, order = int(input()), int(input()) data = [] # 不能用字典保存,因为可能有名字是重复的 for _ in range(n): name, score = input().split() data.append((name, int(score))) if order: for i in sorted(data, key=lambda x:x[1]): # 升序 ...
牛客983488317号:名字重复也能用字典: 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 点赞 评论 收藏
分享

创作者周榜

更多
关注他的用户也关注了:
牛客网
牛客企业服务