Simple Game

시간 제한1초메모리 제한2048 MB

요약
2행 n열 격자에서 (1,1)의 앨리스와 (2,n)의 밥이 서로 방문하지 않은 칸으로 말을 옮길 때, 둘 다 최선을 다할 경우 앨리스가 얻는 점수를 구한다.
난이도

어려움10점 중 8점

유형
게임 이론, 그리디, 누적 합, 동적 계획법
정답자
아직 제출이 없습니다

문제

Alice and Bob like playing games. Today they play on a special grid with 22 rows and nn columns. Alice and Bob each have a chess piece, starting at (1,1)(1,1) and (2,n)(2,n), respectively. They will take turns moving their chess piece, with Alice going first.

In each turn, they can choose to stay still or move the chess piece to any point adjacent horizontally or vertically which has not been visited by the other's piece. The game will end after 10101010^{10^{10}} turns.

Every point in this grid has a non-negative weight. For each player, the score that he/she gets is the sum of the weights of all the points his/her chess piece has visited. The weight is counted only once, even if the piece visited a point multiple times.

Both Alice and Bob want to maximize the score that they get. As a spectator, you want to know the score that Alice gets if both of them play optimally.

입력

The first line contains an integer tt, the number of test cases (1≤t≤5⋅1041 \le t \le 5 \cdot 10^4). The test cases follow.

The first line of each test case contains a single integer nn representing the size of the grid (1≤n≤1051 \le n \le 10^5).

The second line of each test case contains nn integers a_1,1,a_1,2,…,a_1,na\_{1,1},a\_{1,2},\ldots,a\_{1,n}. The ii-th of them represents the weight of point (1,i)(1,i).

The third line of each test case contains nn integers a_2,1,a_2,2,…,a_2,na\_{2,1},a\_{2,2},\ldots,a\_{2,n}. The ii-th of them represents the weight of point (2,i)(2,i).

It is guaranteed that 0≤a_i,j≤1090 \le a\_{i,j} \le 10^9, and the sum of nn across all test cases will not exceed 2.5⋅1052.5 \cdot 10^5.

출력

For each test case, print a line with a single integer: the score that Alice gets if both players play optimally.

예제1

  1. 예제 1

    입력
    4
    2
    1 4
    2 1
    3
    1 1 4
    5 1 4
    4
    1 9 4 9
    1 0 0 1
    7
    3 1 4 1 5 9 2
    6 5 3 5 8 9 8
    
    예상 출력
    5
    6
    15
    25