#python

Algorithm/백준(파이썬)

백준 10971 파이썬(Python) 문제풀이 외판원순회 2

문제링크:https://www.acmicpc.net/problem/10971 import sys input = sys.stdin.readline n = int(input()) costs = [list(map(int, input().split())) for _ in range(n)] visited = [0] * n # 방문했는지 안했는지 sum_cost = 0 # 방문비용 합 ans = sys.maxsize def dfs(depth, x): global sum_cost, ans if depth == n - 1: # 종료 조건 if costs[x][0]: sum_cost += costs[x][0] if sum_cost < ans: # 최소값 비교 ans = sum_cost sum_cost -= costs[x..

김상주
'#python' 태그의 글 목록