https://www.acmicpc.net/problem/9465
# 2023.01.02
import sys
input = sys.stdin.readline
t = int(input()) #test case
for i in range(t):
col = int(input())
sticker = [list(map(int, input().split())) for _ in range(2)]
for j in range(1, col):
if j==1:
sticker[0][1]+=sticker[1][0]
sticker[1][1]+=sticker[0][0]
else:
sticker[0][j]+=max(sticker[1][j-1], sticker[1][j-2])
sticker[1][j]+=max(sticker[0][j-1], sticker[0][j-2])
print((max(sticker[0][col-1], sticker[1][col-1])))
sticker.clear()
'Problem Solving > BOJ' 카테고리의 다른 글
[Brute Force] 7568 덩치 (1) | 2023.01.03 |
---|---|
[DP] 11660 구간합구하기5 (1) | 2023.01.02 |
[Recursive] 1991 트리순회 (0) | 2023.01.02 |
[DP] 1932 정수 삼각형 (0) | 2023.01.02 |
[Divide and Conquer] 1629 곱셈 (0) | 2023.01.01 |