Kerry's game
time limit per test:3s
memory limit per test:256MB
and are playing a little game.
There are stones. and take turns picking stones, with going first. Each person can only pick one stone at a time until all the stones are gone. Each stone has two attributes, and .
When picks a stone, he earns points, and when picks a stone, he earns points. The total score for each person is the sum of the points they earn when picking a stone. Both players want to maximize the difference between their scores, aiming to have their own score minus the opponent's score as large as possible.
The question is, what is the final result of score minus score?
The first line contains a positive integer , representing the number of test cases, where .
Next, for each test case, the following format is repeated:
The first line contains a positive integer,, where . The nextlines contain two integers, and , representing the two attributes of the i-th stone. The values of and satisfy .
For each test case, output one line containing an integer representing the answer.
2 3 0 2 1 2 3 3 3 1 0 2 3 0 4
1 -1
时间限制: 3s
内存限制:256MB
和 在玩一个小游戏。
一共有块石头。 和 轮流拣石头, 先拣。每人每次只能捡一块石头,直到所有石头都捡完为止。每块石头都有两个属性: 和 。
当 选中一块石头时,他会获得 分,而当 选中一块石头时,他会获得 分。每个人的总得分就是他们挑选石头时获得的分数总和。两位玩家都希望最大限度地扩大自己的分数差,力求自己的分数减去对手的分数越大越好。
问题是, 的分数减去 的分数的最终结果是什么?
第一行包含一个正整数 ,表示测试案例的数量,其中 。
接下来,针对每个测试用例,重复以下格式:
第一行包含一个正整数 ,其中 。
接下来的 行包含两个整数 和 ,分别代表第块石头的两个属性。 和 的值满足 。
针对每个测试用例,输出一行包含一个代表答案的整数。
2 3 0 2 1 2 3 3 3 1 0 2 3 0 4
1 -1
难度等级: | 0 |
总通过次数: | 9 |
总提交次数: | 51 |