Created
March 22, 2019 00:47
-
-
Save rpf5573/b6447c32ed116d97bef596b5c2d32a19 to your computer and use it in GitHub Desktop.
RGB집
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from : https://www.acmicpc.net/problem/1149 | |
def solution(N, table): | |
i = 1 | |
while( i < len(table) ): | |
for m in range(3): | |
target = table[i][m] | |
for z in range(3): | |
if m != z: | |
s = target + table[i-1][z] | |
if table[i][m] == target or table[i][m] > s: | |
table[i][m] = s | |
i = i + 1 | |
return min(table[len(table) - 1]) | |
i = 0 | |
n = int(input()) | |
table = [0 for _ in range(n)] | |
while i < n: | |
table[i] = list(map(int, input().split())) | |
i = i + 1 | |
print(solution(n, table)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment