https://www.acmicpc.net/problem/9465
import copy
T = int(input())
for _ in range(T):
sticker = []
n = int(input())
for _ in range(2):
line = [0]
line.extend(list(map(int, input().split(' '))))
sticker.append(line)
dp = copy.deepcopy(sticker)
for sticker_index in range(2, n + 1):
dp[0][sticker_index] = max(dp[1][sticker_index - 2], dp[1][sticker_index - 1]) \
+ sticker[0][sticker_index]
dp[1][sticker_index] = max(dp[0][sticker_index - 2], dp[0][sticker_index - 1]) \
+ sticker[1][sticker_index]
print(max(dp[0][n], dp[1][n]))
'Problem-solving > 백준' 카테고리의 다른 글
백준 - 바이러스(2606번) (Python3) (0) | 2020.05.28 |
---|---|
백준 - 보물(1026번) (Python3) (0) | 2020.05.26 |
백준 - 퇴사(14501번) (Python3) (0) | 2020.05.23 |
백준 - 문자열(1120번) (Python3) (0) | 2020.05.23 |
백준 - 거스름돈(5585번) (Python3) (0) | 2020.05.23 |
댓글