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 <…
2091: [Poi2010]The Minima Game Time Limit: 10 Sec  Memory Limit: 259 MBSubmit: 243  Solved: 163[Submit][Status] Description 给出N个正整数,AB两个人轮流取数,A先取.每次可以取任意多个数,直到N个数都被取走.每次获得的得分为取的数中的最小值,A和B的策略都是尽可能使得自己的得分减去对手的得分更大.在这样的情况下,最终A的得分减去B的得分为多少. Input 第一行一个正整…
2091: [Poi2010]The Minima Game DP 链接 https://www.lydsy.com/JudgeOnline/problem.php?id=2091 思路 这类问题好迷呀. 我们先从小到大sort 先手一定是个后缀. 因为你不能留下大数让对手选呀. 然后后手就在你选择的i前面选([1,i-1])后手及其之后的操作. f[i]表示前i个里面先手的最大值 f[i]=min(f[i-1],a[i]-f[i-1]) 要不这个i点没有贡献,先手是f[i-1],要不就是选这个…
2091: [Poi2010]The Minima Game 链接 分析: 首先排序后,一定是选的连续的一段. f[i]表示前i个位置,先手-后手的最大得分. 那么考虑第i个位置是否选,如果选,先手选的就是从i开始到i的一段,后手在1到i-1就变成了先手,所以就是a[i]-f[i-1]. 否则第i个位置不选,直接从i-1转移即可. 代码: #include<cstdio> #include<algorithm> #include<iostream> #include&l…
P3507 [POI2010]GRA-The Minima Game 题目描述 Alice and Bob learned the minima game, which they like very much, recently. The rules of the game are as follows. A certain number of cards lies on a table, each inscribed with a positive integer. The players m…
题目描述 给出N个正整数,AB两个人轮流取数,A先取.每次可以取任意多个数,直到N个数都被取走.每次获得的得分为取的数中的最小值,A和B的策略都是尽可能使得自己的得分减去对手的得分更大.在这样的情况下,最终A的得分减去B的得分为多少. 输入 第一行一个正整数N (N <= 1,000,000),第二行N个正整数(不超过10^9). 输出 一个正整数,表示最终A与B的分差. 样例输入 3 1 3 1 样例输出 2 题解 dp 不妨倒着想,设f[i]为剩余前i小的数时先手与后手的最大差值. 由于先手…
题目描述 Alice and Bob learned the minima game, which they like very much, recently. The rules of the game are as follows. A certain number of cards lies on a table, each inscribed with a positive integer. The players make alternate moves, Alice making t…
取数游戏 game bzoj-1978 BeiJing-2010 题目大意:给定一个$n$个数的$a$序列,要求取出$k$个数.假设目前取出的数是$a_j$,那么下次取出的$a_k$必须保证:$j<k$且$gcd(a_j,a_k)/reL$.问最多能取出多少个数. 注释:$1\le n\le 5\cdot 10^4$,$2\le L \le a_i\le 10^6$. 想法: 显然可以用动态规划解决. 状态:$dp_i$表示强制选第$i$个数,前$i$个数中最多能取多少个数. 转移是$O(n^2…
题目描述 Alice and Bob learned the minima game, which they like very much, recently. The rules of the game are as follows. A certain number of cards lies on a table, each inscribed with a positive integer. The players make alternate moves, Alice making t…
Description 每次可以任取数字,使用最优策略让差最大. Sol DP. 一开始我写了个单调队列贪心,然后狂WA不止... 正着做有后效性,因为前面的决策无法保证在后面是最优秀的,但如果倒这做就没有后效性了..感觉倒着做这种想法总是容易忽略,它对前面的影响应该多考虑一下. 然后DP就可以了...比较简单的DP.. Code /************************************************************** Problem: 2091 User:…