The Minima Game bzoj-2091 Poi-2010

题目大意:给出N个正整数,AB两个人轮流取数,A先取。每次可以取任意多个数,直到N个数都被取走。每次获得的得分为取的数中的最小值,A和B的策略都是尽可能使得自己的得分减去对手的得分更大。在这样的情况下,最终A的得分减去B的得分为多少。

注释:$1\le n\le 10^6$。


想法:显然从大到小依次选。

之后暴力地dp,根本意义上是一种模拟贪心。

Code:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 1000010
using namespace std;
int a[N];
int main()
{
int n; cin >> n ; for(int i=1;i<=n;i++) scanf("%d",&a[i]);
sort(a+1,a+n+1); int x=0;
for(int i=1;i<=n;i++) x=max(a[i]-x,x);
cout << x << endl ;
return 0;
}

小结:水题。

[bzoj2091][Poi2010]The Minima Game_动态规划的更多相关文章

  1. BZOJ2091: [Poi2010]The Minima Game

    2091: [Poi2010]The Minima Game Time Limit: 10 Sec  Memory Limit: 259 MBSubmit: 243  Solved: 163[Subm ...

  2. bzoj2091: [Poi2010]The Minima Game DP

    2091: [Poi2010]The Minima Game DP 链接 https://www.lydsy.com/JudgeOnline/problem.php?id=2091 思路 这类问题好迷 ...

  3. 2091: [Poi2010]The Minima Game

    2091: [Poi2010]The Minima Game 链接 分析: 首先排序后,一定是选的连续的一段. f[i]表示前i个位置,先手-后手的最大得分. 那么考虑第i个位置是否选,如果选,先手选 ...

  4. 洛谷 P3507 [POI2010]GRA-The Minima Game

    P3507 [POI2010]GRA-The Minima Game 题目描述 Alice and Bob learned the minima game, which they like very ...

  5. 【bzoj2091】[Poi2010]The Minima Game dp

    题目描述 给出N个正整数,AB两个人轮流取数,A先取.每次可以取任意多个数,直到N个数都被取走.每次获得的得分为取的数中的最小值,A和B的策略都是尽可能使得自己的得分减去对手的得分更大.在这样的情况下 ...

  6. 洛谷P3507 [POI2010]GRA-The Minima Game

    题目描述 Alice and Bob learned the minima game, which they like very much, recently. The rules of the ga ...

  7. [bzoj1978][BeiJing2010]取数游戏 game_动态规划_质因数分解

    取数游戏 game bzoj-1978 BeiJing-2010 题目大意:给定一个$n$个数的$a$序列,要求取出$k$个数.假设目前取出的数是$a_j$,那么下次取出的$a_k$必须保证:$j&l ...

  8. P3507 [POI2010]GRA-The Minima Game

    题目描述 Alice and Bob learned the minima game, which they like very much, recently. The rules of the ga ...

  9. BZOJ 2091: [Poi2010]The Minima Game

    Description 每次可以任取数字,使用最优策略让差最大. Sol DP. 一开始我写了个单调队列贪心,然后狂WA不止... 正着做有后效性,因为前面的决策无法保证在后面是最优秀的,但如果倒这做 ...

随机推荐

  1. poj3040 Allowance

    思路: 贪心. 看了题解说是 先把面值从大到小排序然后从头往尾扫,只要不超额,能取多少去多少然后如果还有剩余,就从尾往头扫,尽量取,让他恰好超额 不过并不懂证明. 实现: #include <i ...

  2. 绿化VSCode

    通过啃源码, 终于找到了解决办法, 设置环境变量: VSCODE_APPDATA=C:\Program Files\VSCode\UserData VSCODE_EXTENSIONS=%VSCODE_ ...

  3. iOS programming Delegation and Text Input

    iOS programming Delegation and Text Input  1.1 Text Fields    CGRect textFieldRect = CGRectMake(40, ...

  4. 【PostgreSQL-9.6.3】进程及体系结构

    本文主要讲述了PG的几个主要进程,以及PG的核心架构.进程和体系结构详见下图: 从上面的体系结构图可以看出来,PG使用经典的C/S架构,进程架构.在服务器端有主进程.服务进程.子进程.共享内存以及文件 ...

  5. JavaScript——class与原型对象

    原型对象的意义 通过new 一个构造函数,我们能够获得一个实例,在new 的过程中,程序会在内存中申请一块区域,同时我们可以加参数,所以每个对象都不一样. 原型对象则是同一个构造函数 new 出来的所 ...

  6. 本地连接批处理修改IP

    例子: 本地连接修改IP netsh interface ip delete dns "本地连接" addr=allnetsh interface ip add dns " ...

  7. HDU_1542_(树状数组)

    Stars Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

  8. oracle 时区

    select sysdate from dual;select systimestamp from dual;select localtimestamp from dual;select curren ...

  9. 几个net命令

    A.显示当前工作组服务器列表 net view,当不带选项使用本命令时,它就会显示当前域或网络上的计算机上的列表.  比如:查看这个IP上的共享资源,就可以  C:\\>net view 192 ...

  10. selenium兼容非标准chrome内核的浏览器

    多浏览器兼容性测试(1) RIDE已经支持多浏览器兼容性测试,例如: firefox ie chrome safari 但是,项目要求支持360极速和360安全浏览器.所以,我们需要增加代码让RIDE ...