gems gems gems

TimeLimit:1000MS  MemoryLimit:32768KB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description
Now there are $n$ gems, each of which has its own value. Alice and Bob play a game with these $n$ gems.
They place the gems in a row and decide to take turns to take gems from left to right.
Alice goes first and takes 1 or 2 gems from the left. After that, on each turn a player can take $k$ or $k+1$ gems if the other player takes $k$ gems in the previous turn. The game ends when there are no gems left or the current player can't take $k$ or $k+1$ gems.
Your task is to determine the difference between the total value of gems Alice took and Bob took. Assume both players play optimally. Alice wants to maximize the difference while Bob wants to minimize it.
Input
The first line contains an integer $T$ ($1\leq T \leq 10$), the number of the test cases.
For each test case:
the first line contains a numbers $n$ ($1\leq n \leq 20000$);
the second line contains n numbers: $V_1, V_2\dots V_n$. ($-100000\leq V_i \leq 100000$)
Output
For each test case, print a single number in a line: the difference between the total value of gems Alice took and the total value of gems Bob took.
SampleInput
1
3
1 3 2
SampleOutput
4
Submit
题目统计信息详细
总AC数0
通过人数0
尝试人数0
总提交量0
AC率0.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签
出处

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: