QOJ.ac

QOJ

حد الوقت: 2.0 s حد الذاكرة: 256 MB مجموع النقاط: 100 قابلة للهجوم ✓

#12369. Card Game

الإحصائيات

Alice and Bob are playing a card game.

There are $2n$ cards stacked in a pile. The $i$-th card from the top ($1 \le i \le 2n$) is labeled with a number $a_i$. When dealing the cards, the cards in the pile are indexed from top to bottom as $1, 2, \dots, 2n$. Cards with odd indices are dealt to one player, and cards with even indices are dealt to the other player. This means Alice will receive $n$ cards whose indices are either all odd or all even.

For a player, the larger the sum of the numbers on the cards they receive, the more favorable the game situation is for them. Therefore, Alice wants to maximize the sum of the numbers on the cards she receives in the worst-case scenario. To achieve this, Alice can perform exactly one of the following operations on the current pile of cards:

  • Remove one card from the current pile and insert it into any position in the pile. Note that the indices of the cards when dealing will change.

For example, if the numbers on the cards in the pile from top to bottom are initially $1, 2, 3, 4$, when dealing, one player receives $1, 3$ and the other player receives $2, 4$. Alice can choose to remove the second card and insert it after the last card, so the pile becomes $1, 3, 4, 2$. When dealing, one player receives $1, 4$ and the other player receives $3, 2$.

You need to find the maximum value of the sum of the numbers on the cards Alice receives in the worst-case scenario after Alice performs exactly one operation.

Input

The problem contains multiple test cases. The first line contains an integer $t$ ($1 \le t \le 10^4$), representing the number of test cases. For each test case: The first line contains an integer $n$ ($1 \le n \le 10^5$), representing the number of cards each player receives. The second line contains $2n$ integers $a_1, a_2, \dots, a_{2n}$ ($1 \le a_i \le 10^9$), representing the numbers labeled on the cards in the pile. For each test case, it is guaranteed that $\sum n$ does not exceed $10^5$.

Output

For each test case, output a single integer representing the maximum value of the sum of the numbers Alice receives in the worst-case scenario after performing exactly one operation.

Examples

Input 1

4
2
1 3 2 4
1
1000000000 1
3
1 1 2 3 5 8
4
1 2 4 8 16 32 64 128

Output 1

5
1
9
106

Note

The first example is the one described in the problem statement. When dealing, the sum of the numbers for one player is $1 + 4 = 5$, and the sum of the numbers for the other player is $3 + 2 = 5$. It can be proven that this is the maximum value that can be obtained.

In the second example, no matter what operation is performed, one player will always receive $1$ and the other player will receive $10^9$. Therefore, in the worst-case scenario, Alice can only receive $1$, which is the answer.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.