백준 17254번: 키보드 이벤트 #Python

ColorlessDia·2024년 9월 9일

algorithm/baekjoon

목록 보기
295/836
import sys

N, M = map(int, sys.stdin.readline().split())

history = [sys.stdin.readline().rstrip().split() for _ in range(M)]

sorted_history = sorted(history, key=lambda x: (int(x[1]), int(x[0])))

result = ''

for keyboard, second, key in sorted_history:
    result += key

print(result)

0개의 댓글