We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9ef187d commit d5e373aCopy full SHA for d5e373a
1 file changed
live10/test101/문제2/백한결.py
@@ -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