-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path9465.py
More file actions
31 lines (22 loc) · 759 Bytes
/
Copy path9465.py
File metadata and controls
31 lines (22 loc) · 759 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
import sys
N = int(sys.stdin.readline())
sticker = []
M = []
for i in range(N):
temp = int(sys.stdin.readline())
M.append(temp)
line1 = list(map(int,sys.stdin.readline().split()))
line2 = list(map(int,sys.stdin.readline().split()))
sticker.append([line1, line2])
for i in range(N):
dp = [[0] * M[i] for x in range(2)]
dp[0][0] = sticker[i][0][0]
dp[1][0] = sticker[i][1][0]
for j in range(1,M[i]):
if j == 1:
dp[0][1] = sticker[i][1][0] + sticker[i][0][1]
dp[1][1] = sticker[i][0][0] + sticker[i][1][1]
else:
dp[0][j] = max(sticker[i][0][j] + dp[1][j-1], sticker[i][0][j] + dp[1][j-2])
dp[1][j] = max(sticker[i][1][j] + dp[0][j-1], sticker[i][1][j] + dp[0][j-2])
print(max(max(dp[0]), max(dp[1])))