최소비용구하기 3

[백준] 11779 최소비용 구하기 2 python

https://www.acmicpc.net/problem/11779 11779번: 최소비용 구하기 2 첫째 줄에 도시의 개수 n(1≤n≤1,000)이 주어지고 둘째 줄에는 버스의 개수 m(1≤m≤100,000)이 주어진다. 그리고 셋째 줄부터 m+2줄까지 다음과 같은 버스의 정보가 주어진다. 먼저 처음에는 그 버스 www.acmicpc.net 최소 거리를 구하고 경로도 같이 구해야하는데 다익스트라 알고리즘에 경로도 같이 추가하면 쉽게 풀린다. # import sys; input = sys.stdin.readline from heapq import heappop, heappush def dijkstra(s, e, adj_list): INF = 987654321 ret = None # dist, route ..

STUDY/Algorithm 2022.02.15

[백준] 1916 최소비용 구하기 python

https://www.acmicpc.net/problem/1916 1916번: 최소비용 구하기 첫째 줄에 도시의 개수 N(1 ≤ N ≤ 1,000)이 주어지고 둘째 줄에는 버스의 개수 M(1 ≤ M ≤ 100,000)이 주어진다. 그리고 셋째 줄부터 M+2줄까지 다음과 같은 버스의 정보가 주어진다. 먼저 처음에는 그 www.acmicpc.net import sys; input = sys.stdin.readline from heapq import heappop, heappush inf = 100000000 # 최대값 (max(N)-1) * max(w) N = int(input()) # 1000 M = int(input()) # 100000 link_list = [list() for _ in range(N ..

STUDY/Algorithm 2021.07.15

[백준] 1916 최소비용 구하기 python

www.acmicpc.net/problem/1916 1916번: 최소비용 구하기 첫째 줄에 도시의 개수 N(1 ≤ N ≤ 1,000)이 주어지고 둘째 줄에는 버스의 개수 M(1 ≤ M ≤ 100,000)이 주어진다. 그리고 셋째 줄부터 M+2줄까지 다음과 같은 버스의 정보가 주어진다. 먼저 처음에는 그 www.acmicpc.net import sys input = sys.stdin.readline from heapq import heappop, heappush N = int(input()) M = int(input()) link_arr = [list() for _ in range(N + 1)] for _ in range(M): st, en, we = map(int, input().split()) link..

STUDY/Algorithm 2021.04.29