Skip to content

Commit d5d3e3f

Browse files
committed
[BOJ] RGB거리 / 실버 1 / 40분
https://www.acmicpc.net/problem/1149
1 parent c02235f commit d5d3e3f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
n = int(input())
2+
3+
cost = []
4+
minCost = -int(1e9)
5+
dp = [[0]*3 for _ in range(n)]
6+
for i in range(n):
7+
cost.append(list(map(int, input().split())))
8+
9+
dp[0][0], dp[0][1], dp[0][2] = cost[0][0], cost[0][1], cost[0][2]
10+
11+
for i in range(1, n):
12+
dp[i][0] = min(dp[i-1][1] + cost[i][0], dp[i-1][2] + cost[i][0])
13+
dp[i][1] = min(dp[i-1][0] + cost[i][1], dp[i-1][2] + cost[i][1])
14+
dp[i][2] = min(dp[i-1][0] + cost[i][2], dp[i-1][1] + cost[i][2])
15+
16+
print(min(dp[n-1][0], dp[n-1][1], dp[n-1][2]))

0 commit comments

Comments
 (0)