Adjacents are not allowed
Submissions: 2813   Accuracy:

35.57%

  Difficulty: Easy   Marks: 2

You have a rectangular grid of dimension 2 x N. You need to find out the maximum sum such that no two chosen numbers are adjacent, vertically, diagonally or horizontally, .

Input:

The first line of input contains an integer T denoting the number of test cases.
The first line of each test case is N,number of columns in a grid.

Next two lines describes the 2*N grid.

Output:

Print the output for each test case in a seprate line.

Constraints:

1 <=T<= 100
1 <=N<= 100
0 <=arr[i]<= 70

Example:

Input:

1
3
1 4 5
2 0 0

Output:

7

** For More Input/Output Examples Use 'Expected Output' option **

Author: bhawnamait


Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.