题解 | #成绩排序#

成绩排序

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

import sys

n=int(input())
px=False if int(input()) else True
names=[]
scores={}
i=0
for line in sys.stdin:
    a = line.split()
    names.append(a[0])
    scores[i]=int(a[1])
    i+=1
        
s=sorted(scores.items(), key=lambda x:x[1], reverse=px)

for i in s:
    print(f'{names[i[0]]} {i[1]}')

全部评论

相关推荐

Gaynes:查看图片
点赞 评论 收藏
分享
05-22 12:44
已编辑
门头沟学院 golang
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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