import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(br.readLine());
int[][] dp = new int[100_001][3];
while(t-- > 0) {
int n = Integer.parseInt(br.readLine());
String[] arr1 = br.readLine().split(" ");
String[] arr2 = br.readLine().split(" ");
int max = 0;
for(int i=1; i<=n; i++) {
dp[i][0] = Math.max(dp[i-1][0], Math.max(dp[i-1][1], dp[i-1][2]));
dp[i][1] = Math.max(dp[i-1][0], dp[i-1][2])+Integer.parseInt(arr1[i-1]);
dp[i][2] = Math.max(dp[i-1][0], dp[i-1][1])+Integer.parseInt(arr2[i-1]);
}
max = Math.max(dp[n][0], Math.max(dp[n][1], dp[n][2]));
System.out.println(max);
}
}
}
'Problem Solving > BOJ' 카테고리의 다른 글
[Silver 1] 1932번 정수 삼각형 (0) | 2022.03.29 |
---|---|
[Silver 1] 2156번 포도주 시식 (0) | 2022.03.29 |
[Silver 1] 11057번 오르막 수 (0) | 2022.03.29 |
[Silver 1] 1309번 동물원 (0) | 2022.03.29 |
[Silver 1] 1149번 RGB거리 (0) | 2022.03.29 |