Skip to content

Commit d5e373a

Browse files
author
hangyeol
committed
101차 2번 문제 풀이
1 parent 9ef187d commit d5e373a

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
def main():
2+
N = int(input())
3+
cost = [list(map(int, input().split())) for _ in range(N)]
4+
5+
dp = [[0] * 3 for _ in range(N)]
6+
7+
dp[0][0] = cost[0][0]
8+
dp[0][1] = cost[0][1]
9+
dp[0][2] = cost[0][2]
10+
11+
for i in range(1, N):
12+
dp[i][0] = min(dp[i-1][1], dp[i-1][2]) + cost[i][0]
13+
dp[i][1] = min(dp[i-1][0], dp[i-1][2]) + cost[i][1]
14+
dp[i][2] = min(dp[i-1][0], dp[i-1][1]) + cost[i][2]
15+
16+
print(min(dp[N-1]))
17+
18+
19+
if __name__ == "__main__":
20+
main()

0 commit comments

Comments
 (0)