1555C.md (2099B)
1 Source: https://codeforces.com/problemset/problem/1555/C 2 3 C. Coin Rows 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 Alice and Bob are playing a game on a matrix, consisting of $2$ rows and $m$ columns. The cell in the $i$-th row in the $j$-th column contains $a_{i, j}$ coins in it. 22 23 Initially, both Alice and Bob are standing in a cell $(1, 1)$. They are going to perform a sequence of moves to reach a cell $(2, m)$. 24 25 The possible moves are: 26 27 * Move right — from some cell $(x, y)$ to $(x, y + 1)$; 28 * Move down — from some cell $(x, y)$ to $(x + 1, y)$. 29 30 First, Alice makes all her moves until she reaches $(2, m)$. She collects the coins in all cells she visit (including the starting cell). 31 32 When Alice finishes, Bob starts his journey. He also performs the moves to reach $(2, m)$ and collects the coins in all cells that he visited, but Alice didn't. 33 34 The score of the game is the total number of coins Bob collects. 35 36 Alice wants to minimize the score. Bob wants to maximize the score. What will the score of the game be if both players play optimally? 37 38 Input 39 40 The first line contains a single integer $t$ ($1 \le t \le 10^4$) — the number of testcases. 41 42 Then the descriptions of $t$ testcases follow. 43 44 The first line of the testcase contains a single integer $m$ ($1 \le m \le 10^5$) — the number of columns of the matrix. 45 46 The $i$-th of the next $2$ lines contain $m$ integers $a_{i,1}, a_{i,2}, \dots, a_{i,m}$ ($1 \le a_{i,j} \le 10^4$) — the number of coins in the cell in the $i$-th row in the $j$-th column of the matrix. 47 48 The sum of $m$ over all testcases doesn't exceed $10^5$. 49 50 Output 51 52 For each testcase print a single integer — the score of the game if both players play optimally. 53 54 Example 55 56 Input 57 58 ``` 59 3 60 3 61 1 3 7 62 3 5 1 63 3 64 1 3 9 65 3 5 1 66 1 67 4 68 7 69 ``` 70 71 Output 72 73 ``` 74 7 75 8 76 0 77 ``` 78 79 Note 80 81 The paths for the testcases are shown on the following pictures. Alice's path is depicted in red and Bob's path is depicted in blue. 82 83 