挖掘機技術哪家強(20)
阿新 • • 發佈:2018-12-13
題目描述
為了用事實說明挖掘機技術到底哪家強,PAT組織了一場挖掘機技能大賽。現請你根據比賽結果統計出技術最強的那個學校。
輸入描述:
輸入在第1行給出不超過105的正整數N,即參賽人數。隨後N行,每行給出一位參賽者的資訊和成績,包括其所代表的學校的編號、及其比賽成績(百分制),中間以空格分隔。
輸出描述:
在一行中給出總得分最高的學校的編號、及其總分,中間以空格分隔。題目保證答案唯一,沒有並列。
輸入例子:
6 3 65 2 80 1 100 2 70 3 40 3 0
輸出例子:
2 150
程式碼:python3
n = int(input()) name = [] score = [] for i in range(n): N = list(input().split(sep=' ')) M = int(N[0]),int(N[1]) if M[0] not in name: name = name+[M[0]] score = score+[0] if M[0] in name: index = name.index(M[0]) score[index] = score[index] + M[1] MAX = max(score) index = score.index(MAX) NAME = name[index] print('%d %d'%(NAME,MAX))