조립라인

2021. 10. 6. 17:46Algorithm

    목차
반응형
import sys

N = int(sys.stdin.readline())

grid = [[0]*2 for _ in range(N)]
tran = [[0]*2 for _ in range(N)]

for i in range(N - 1):
    A, B, AB, BA = map(int, sys.stdin.readline().split())
    grid[i][0] = A
    grid[i][1] = B
    tran[i][0] = AB
    tran[i][1] = BA

AN, BN = map(int, sys.stdin.readline().split())

grid[-1][0] = AN
grid[-1][1] = BN

for i in range(N - 1):
    grid[i + 1][0] += min(grid[i][0], grid[i][1] + tran[i][1])
    grid[i + 1][1] += min(grid[i][0] + tran[i][0], grid[i][1])

print(min(grid[-1]))

 

 

반응형

'Algorithm' 카테고리의 다른 글

성적평균  (0) 2021.10.08
징검다리  (0) 2021.10.07
알고리즘: 바이러스  (0) 2021.09.30
금고털이  (0) 2021.09.30
우물 안 개구리  (0) 2021.09.29