#P13309. 演剧

    ID: 12287 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>博弈论洛谷原创O2优化洛谷月赛Ad-hoc分类讨论

演剧

Description

Yuki and K are playing a game on a sequence of length nn.

Yuki and K take turns to act. Yuki moves first. In each operation, the current player can split the sequence into two non-empty parts at a division point, and then the opponent in the game will delete one of the parts. The game continues with the remaining part.

Specifically, in the first round, Yuki splits and K deletes; in the second round, K splits and Yuki deletes; in the third round, Yuki splits and K deletes, and so on.

The game ends when only one number remains and no further operations can be performed. Yuki wants to maximize the last remaining number, while K wants to minimize it.

Assuming both players are infinitely smart, determine the final remaining number.

Input Format

The input contains TT test cases. The first line of input has an integer TT.

For each test case, the first line contains a positive integer nn.

The second line of each test case contains nn positive integers, where the ii-th integer is aia_i.

Output Format

For each test case, output an integer representing the final remaining number.

2
5
1 4 3 1 5
4
1 3 3 1
3
3

Hint

Explanation for the first sample: If Yuki chooses to split the sequence into the left 2 numbers and the right 3 numbers:

  • If K deletes the right part, the remaining sequence is 11 and 44. Yuki can then ensure the final number is 44 when K splits.
  • If K deletes the left part, the remaining sequence is 3,1,53, 1, 5. No matter how K splits next, Yuki can ensure the answer is no less than 33.

Further analysis shows that the answer is 33.

Test nn\le
11 55
232\sim 3 100100
464\sim 6 10001000
7107\sim 10 10510^5

For all data, 1T101\le T\le 10, 1n1051\le n\le 10^5, 1ai1091\le a_i\le 10^9.