[DP][1149]

Hyon uk Jo·2023년 7월 24일
0
import sys
input = sys.stdin.readline

n = int(input())
RGB = []
for i in range(n):
    RGB.append(list(map(int, input().strip().split())))
    
    
for i in range(1, n):
    # 빨간집
    RGB[i][0] = min(RGB[i-1][1], RGB[i-1][2]) + RGB[i][0]
    # 초록집
    RGB[i][1] = min(RGB[i-1][0], RGB[i-1][2]) + RGB[i][1]
    # 파란집
    RGB[i][2] = min(RGB[i-1][0], RGB[i-1][1]) + RGB[i][2]
    
print(min(RGB[n-1]))
    
profile
누구나 AI를 할 수 있게 쉽게 설명하기!

0개의 댓글