当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6199:gems gems gems

题目描述
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.
输入解释
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$)
输出解释
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.
输入样例
1
3
1 3 2
输出样例
4
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6199

最后修改于 2020-10-25T23:29:14+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 32768/32768K(Java/Others)