Logo
(追記) (追記ここまで)

33392번 - Simple Game 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB888100.000%

문제

Alice and Bob like playing games. Today they play on a special grid with 2ドル$ rows and $n$ columns. Alice and Bob each have a chess piece, starting at $(1,1)$ and $(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 10ドル^{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 $t,ドル the number of test cases (1ドル \le t \le 5 \cdot 10^4$). The test cases follow.

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

The second line of each test case contains $n$ integers $a_{1,1},a_{1,2},\ldots,a_{1,n}$. The $i$-th of them represents the weight of point $(1,i)$.

The third line of each test case contains $n$ integers $a_{2,1},a_{2,2},\ldots,a_{2,n}$. The $i$-th of them represents the weight of point $(2,i)$.

It is guaranteed that 0ドル \le a_{i,j} \le 10^9,ドル and the sum of $n$ across all test cases will not exceed 2ドル.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

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

예제 출력 1

5
6
15
25

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2023 > Day 7: Peking U Contest A번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /