[백준 1854번] K번째 최단경로 찾기 (Python3)
import sys input = sys.stdin.readline from heapq import * N,M,K = map(int,input().split()) graph = [[] for i in range(N+1)] for _ in range(M): x,y,w = map(int,input().split()) graph[x].append((y,w)) hq = [(0,1)]; distance = [[] for i in range(N+1)] while hq: w,now = heappop(hq) if len(distance[now])==K: if w >= -distance[now][0]: continue else: heappop(distance[now]) heappush(distance[now],-w) f..