import sys

n = int(input())
boss = {}

for _ in range(n):
    inputs = sys.stdin.readline().split()
    boss[inputs[0]] = int(inputs[1])

sorted_b = sorted(boss.items(), key=lambda item: (-item[1], item[0]))

print(sorted_b[0][0])

 

* sorted( dict.items(), key=lambda item: (-item[1], item[0]) )

 >> dict sort하는데 item[1] 기준 reverse로, 그리고 item[0] 기준 사전순으로 정렬하기

 

** dict 맨 처음 key 출력할 때 : dict[0][0]

  dict[0]하면 key, value 같이 출력 / 그럼 value 출력하고 싶으면 dict[0][1]

'HELLO WORLD > BAEKJOON' 카테고리의 다른 글

백준 | 1920 수 찾기  (0) 2025.01.18
백준 | 2566 최댓값  (0) 2025.01.18
백준 | 9012 괄호  (0) 2025.01.18
백준 | 16916 부분 문자열  (0) 2025.01.18
백준 | 1181 단어 정렬  (0) 2025.01.18

+ Recent posts