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. JDK常用类解读--String

    一.字符串的不变性: 文章使用的源码是jdk1.8的.(下同) 1.首先可以看到`String`是`final`类,说明该类不可继承,保证不会被子类改变语义 2.String的值实际上就是一个字符数组 ...

  2. mysql解压缩方式安装和彻底删除

    一.安装mysql (1)将下载下来的mysql压缩文件解压缩到需要安装mysql的目录中 (2)打开解压后的文件夹,复制default.ini文件并重命名为my.ini,此文件的相关配置为: (3) ...

  3. Elasticsearch--集群&时光之门和恢复控制

    节点发现 启动一个Elasticsearch节点时,该节点会开始寻找具有相同集群名字并且可见的主节点.如果找到主节点,该节点加入一个已经组成了的集群:如果没有找到,该节点成为主节点(如果配置允许).形 ...

  4. UI动画效果

    UI界面的动画效果总结 方式1:头尾式 //开始动画 [UIView beginAnimations:nil context:nil]; //设置动画时间 [UIView setAnimationDu ...

  5. SQL优化基础 使用索引(一个小例子)

    按照本文操作和体会,会对sql优化有个基本最简单的了解,其他深入还需要更多资料和实践的学习: 1. 建表: 复制代码代码如下: create table site_user ( id int IDEN ...

  6. SQL Server 零散笔记

    排序显示行号 select Row_Number() over(order by Code) as RowNumber,ID,Code,Name from CBO_ItemMaster 不排序显示行号 ...

  7. 批处理 reg add /?

    C:\Users\Administrator>reg add /? REG ADD KeyName [/v ValueName | /ve] [/t Type] [/s Separator] [ ...

  8. jQuery 冒泡事件

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  9. chattr - 修改文件在Linux第二扩展文件系统(E2fs)上的特有属性

    SYNOPSIS(总览) chattr [ -RV ] [ -v version ] [ mode ] files... DESCRIPTION(描述) chattr 修改文件在Linux第二扩展文件 ...

  10. pytorch笔记:09)Attention机制

    刚从图像处理的hole中攀爬出来,刚走一步竟掉到了另一个hole(fire in the hole*▽*) 1.RNN中的attentionpytorch官方教程:https://pytorch.or ...