牛客华为机试HJ68
作者:互联网
1. 题目描述
2. Solution
import sys
if sys.platform != "linux":
file_in = open("input/HJ68.txt")
sys.stdin = file_in
def solve():
n = int(input().strip())
order = input().strip()
# 0代表从高到低,1代表从低到高
reverse = True if order == "0" else False
data = dict()
for i in range(n):
name, score = input().strip().split()
score = int(score)
if score not in data:
data[score] = [name]
else:
data[score].append(name)
d = list(data.items())
d.sort(key=lambda x: x[0], reverse=reverse)
for score, names in d:
for name in names:
print(f'{name} {score}')
while True:
try:
solve()
except:
break
标签:name,data,strip,sys,牛客,score,input,机试,HJ68 来源: https://www.cnblogs.com/junstat/p/16172602.html