Skip to content

Instantly share code, notes, and snippets.

@rpf5573
Created March 22, 2019 00:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rpf5573/b6447c32ed116d97bef596b5c2d32a19 to your computer and use it in GitHub Desktop.
Save rpf5573/b6447c32ed116d97bef596b5c2d32a19 to your computer and use it in GitHub Desktop.
RGB집
# 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