n = int(input())
house = []
for i in range(n):
house.append(list(map(int, input().split())))
for i in range(1, len(house)):
house[i][0] = min(house[i - 1][1], house[i - 1][2]) + house[i][0]
house[i][1] = min(house[i - 1][0], house[i - 1][2]) + house[i][1]
house[i][2] = min(house[i - 1][0], house[i - 1][1]) + house[i][2]
print(min(house[n - 1][0], house[n - 1][1], house[n - 1][2]))
'문제풀이 > 백준(Boj) 문제풀이' 카테고리의 다른 글
[백준][동적 계획법1] 2579. 계단 오르기(파이썬/Python) (0) | 2021.09.15 |
---|---|
[백준][동적 계획법1] 1932. 정수 삼각형(파이썬/Python) (0) | 2021.09.13 |
[백준][백트래킹] 14888. 연산자 끼워넣기(파이썬/Python) (0) | 2021.09.12 |
[백준][동적 계획법1] 9461. 파도반 수열 (파이썬/Python) (0) | 2021.09.12 |
[백준][동적 계획법1] 1904. 01타일 (파이썬/Python) (0) | 2021.09.10 |