[BOJ] 1149. RGB๊ฑฐ๋ฆฌ(python)
๐๋ฌธ์
๐ช์์ด๋์ด
- ์์น ํ๊ธฐ
ํ์ฌ ์ง๊ณผ ์๊น์ด ๊ฒน์น์ง ์๊ธฐ ๋๋ฌธ์ ์ด์ ์ง์์ ์์น ํ ์๊น ์ค ์ผ ๊ฒ์ผ๋ก ์น ํ๋ค.
๐ฅ์ฝ๋
1
2
3
4
5
6
7
8
9
10
11
12
13
import sys; input = sys.stdin.readline
n = int(input())
paint = []
for _ in range(n):
paint.append(list(map(int,input().split())))
for i in range(1,n):
paint[i][0]+=min(paint[i-1][1],paint[i-1][2])
paint[i][1]+=min(paint[i-1][0],paint[i-1][2])
paint[i][2]+=min(paint[i-1][0],paint[i-1][1])
print(min(paint[-1]))
This post is licensed under CC BY 4.0 by the author.
Comments powered by Disqus.