지나가던 개발자

[Python] 백준 24175번(Tokyo2020) 문제 풀이 본문

PS/Python

[Python] 백준 24175번(Tokyo2020) 문제 풀이

KwonYongHyeon 2022. 10. 25. 18:08

 

from collections import Counter

while True:
    players = []
    for i in range(int(input())):
        d = input().split()
        players.append([int(d[0]), d[2]])
    if players == []:
        break
    players.sort(key=lambda x:x[0])
    print(Counter([x[0] for x in players if x[1] == 'Gold']).most_common(1)[0][0], Counter([x[0] for x in players]).most_common(1)[0][0])

 

파이썬에서 리스트의 최빈값을 구하기 위해서는 from collections import Counter를 해준 후 Counter(리스트).most_common(1)[0][0] 을 하면 된다.

Comments