스티커
Updated:
위 아래를 확인하면서 누적으로 더해나가기
T = int(input())
for tc in range(T):
n = int(input())
arr = [[int(x) for x in input().split()] for i in range(2)]
arr[0][1] = arr[0][1] + arr[1][0]
arr[1][1] = arr[1][1] + arr[0][0]
for j in range(2,n):
for i in range(2):
if(arr[(i+1)%2][j-2]>arr[(i+1)%2][j-1]):
arr[i][j] += arr[(i+1)%2][j-2]
else:
arr[i][j] += arr[(i+1)%2][j-1]
print(max(arr[0][n-1],arr[1][n-1]))
Leave a comment