-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1149.py
More file actions
27 lines (24 loc) · 811 Bytes
/
1149.py
File metadata and controls
27 lines (24 loc) · 811 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
import sys
n = int(input())
# rgb = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]
# if n==1:
# print(min(rgb[0]))
# else:
# for i in range(1,len(rgb)):
# for j in range(3):
# if j == 0:
# min_num = min(rgb[i-1][1],rgb[i-1][2])
# elif j == 1:
# min_num = min(rgb[i - 1][0], rgb[i - 1][2])
# else:
# min_num = min(rgb[i - 1][0], rgb[i - 1][1])
# rgb[i][j] += min_num
# print(min(rgb[n-1]))
dp = [list(map(int,sys.stdin.readline().split()))]
for i in range(1,n):
r, g, b = map(int,sys.stdin.readline().split())
nr = r + min(dp[i-1][1],dp[i-1][2])
ng = g + min(dp[i-1][0],dp[i-1][2])
nb = b + min(dp[i-1][1],dp[i-1][0])
dp.append([nr,ng,nb])
print(min(dp[n-1]))