-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1149.py
More file actions
34 lines (27 loc) · 865 Bytes
/
Copy path1149.py
File metadata and controls
34 lines (27 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# 1149 RGB거리
n = int(input())
d = [[] for _ in range(n)]
for i in range(n):
RGB = list(map(int, input().split()))
R = RGB[0]
G = RGB[1]
B = RGB[2]
if i == 0:
d[i] = [R, G, B]
else:
for j in range(len(d[i - 1])):
prevCol = d[i - 1][j]
if prevCol != 'R' and prevCol != 'G' and prevCol != 'B':
if j % 3 == 0:
d[i].append(999)
d[i].append(prevCol + G)
d[i].append(prevCol + B)
elif j % 3 == 1:
d[i].append(prevCol + R)
d[i].append(999)
d[i].append(prevCol + B)
elif j % 3 == 2:
d[i].append(prevCol + R)
d[i].append(prevCol + G)
d[i].append(999)
print(min(d[n - 1]))