1. Problem
2. My Solution
# dp[i][j] -> i = n, j = 0,1,2 (0 = 선택 x, 1 = 1행, 2 = 2행)
import sys
test_n = int(sys.stdin.readline().rstrip())
for _ in range(test_n):
n = int(sys.stdin.readline().rstrip())
sticker = []
sticker.append([0]+ (list(map(int,sys.stdin.readline().rstrip().split()))))
sticker.append([0]+ (list(map(int,sys.stdin.readline().rstrip().split()))))
dp = [[0,0,0] for _ in range(n+1)]
for i in range(1,n+1):
if i == 1:
dp[i][0] = 0
dp[i][1] = sticker[0][i]
dp[i][2] = sticker[1][i]
else:
dp[i][0] = max(dp[i-1])
dp[i][1] = max(dp[i-1][2]+ sticker[0][i], dp[i-1][0]+ sticker[0][i])
dp[i][2] = max(dp[i-1][1]+ sticker[1][i], dp[i-1][0]+ sticker[1][i])
print(max(dp[n]))
3. Others' Solutions
import sys
input = sys.stdin.readline
for _ in range(int(input())):
n = int(input())
dp = []
dp.append(list(map(int, input().split())))
dp.append(list(map(int, input().split())))
for i in range(1, n):
if i == 1:
dp[0][1] += dp[1][0]
dp[1][1] += dp[0][0]
else:
dp[0][i] += max(dp[1][i-1], dp[1][i-2])
dp[1][i] += max(dp[0][i-1], dp[0][i-2])
print(max(dp[0][n-1], dp[1][n-1]))
4. Learned