Skip to content

Commit 930a362

Browse files
committed
[BOJ] #1149. RGB거리 / 실버1 / 56분 (성공)
1 parent f692d68 commit 930a362

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+
import sys
2+
input = sys.stdin.readline
3+
4+
n = int(input())
5+
cost = []
6+
for i in range(n):
7+
temp = list(map(int, input().split()))
8+
cost.append(temp)
9+
10+
# 0: RED, 1: GREEN, 2: BLUE
11+
for i in range(1, n):
12+
cost[i][0] = min(cost[i-1][1], cost[i-1][2]) + cost[i][0] # RED
13+
cost[i][1] = min(cost[i-1][0], cost[i-1][2]) + cost[i][1] # GREEN
14+
cost[i][2] = min(cost[i-1][0], cost[i-1][1]) + cost[i][2] # BLUE
15+
16+
print(min(cost[-1][0], cost[-1][1], cost[-1][2]))

0 commit comments

Comments
 (0)