这道题涉及了如何一行以空格隔开的形式输入字符串和数字以及自定义排序规则。
import functools
n = int(input())
result = []
for i in range(n):
parts = input().split(' ')
name = parts[0]
yw = int(parts[1])
sx = int(parts[2])
yy = int(parts[3])
result.append([name,yw,sx,yy,i+1])
def my_cmp(a,b):
if a[1]+a[2]+a[3] == b[1]+b[2]+b[3]:
if a[4]>b[4]:
return 1
else:
return -1
else:
if a[1]+a[2]+a[3] < b[1]+b[2]+b[3]:
return 1
else:
return -1
result.sort(key=functools.cmp_to_key(my_cmp))
for i in range(4):
print(result[0][i],end=' ')