[백준 1185번] 유럽여행 (Python3)
import sys input = sys.stdin.readline from heapq import * def findparent(x): if parent[x]!=x: parent[x] = findparent(parent[x]) return parent[x] N,M = map(int,input().split()) cost = [1e6]+[int(input()) for i in range(N)] hq = []; parent = [i for i in range(N+1)] for _ in range(M): a,b,c = map(int,input().split()) heappush(hq,(c*2+cost[a]+cost[b],a,b)) result = 0 while hq: c,a,b = heappop(hq) if..