洛谷 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 make alternate moves, Alice making the first one.
A move consists in picking an arbitrary positive number of cards from the table.
For such move the player receives a number of points equal to the minimum of the numbers inscribed on the cards he collected.
The game ends when the last card is removed from the table.
The goal of each player is maximizing the difference between their and their opponent's score.
Alice and Bob have duly noted that there is an optimal strategy in the game.
Thus they are asking you to write a program that, for a given set of cards, determines the outcome of the game when both players play optimally.
给出N个正整数,AB两个人轮流取数,A先取。每次可以取任意多个数,直到N个数都被取走。每次获得的得分为取的数中的最小值,A和B的策略都是尽可能使得自己的得分减去对手的得分更大。在这样的情况下,最终A的得分减去B的得分为多少。
输入输出格式
输入格式:
In the first line of the standard input there is one integer (
) given, denoting the number of cards.
The second line holds positive integers
(
), separated by single spaces, that are inscribed on the cards.
输出格式:
Your program should print out a single line with a single integer to the standard output - the number of points by which Alice wins over Bob, assuming they both play optimally; if it is Bob who has more points, the result should be negative.
输入输出样例
3
1 3 1
2
思路:
f[i]表示剩下了1..i这个前缀的max(先手-后手)。
枚举先手决策,f[i]=max(a[j]-f[j-1])
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,ans,num[];
int main(){
scanf("%d",&n);
for(int i=;i<=n;i++) scanf("%d",&num[i]);
sort(num+,num++n);
for(int i=;i<=n;i++)
if(ans<num[i]-ans)
ans=num[i]-ans;
printf("%d",ans);
}
洛谷 P3507 [POI2010]GRA-The Minima Game的更多相关文章
- 洛谷P3507 [POI2010]GRA-The Minima Game
题目描述 Alice and Bob learned the minima game, which they like very much, recently. The rules of the ga ...
- 洛谷P3502 [POI2010]CHO-Hamsters感想及题解(图论+字符串+矩阵加速$dp\&Floyd$)
洛谷P3502 [POI2010]CHO-Hamsters感想及题解(图论+字符串+矩阵加速\(dp\&Floyd\)) 标签:题解 阅读体验:https://zybuluo.com/Junl ...
- [洛谷P3501] [POI2010]ANT-Antisymmetry
洛谷题目链接:[POI2010]ANT-Antisymmetry 题目描述 Byteasar studies certain strings of zeroes and ones. Let be su ...
- 洛谷 P3496 [POI2010]GIL-Guilds
P3496 [POI2010]GIL-Guilds 题目描述 King Byteasar faces a serious matter. Two competing trade organisatio ...
- 洛谷 P3505 [POI2010]TEL-Teleportation
P3505 [POI2010]TEL-Teleportation 题目描述 King Byteasar is the ruler of the whole solar system that cont ...
- 【字符串】【hash】【倍增】洛谷 P3502 [POI2010]CHO-Hamsters 题解
这是一道字符串建模+图论的问题. 题目描述 Byteasar breeds hamsters. Each hamster has a unique name, consisting of lo ...
- [洛谷P3509][POI2010]ZAB-Frog
题目大意:有$n$个点,每个点有一个距离(从小到大给出),从第$i$个点跳一次,会跳到距离第$i$个点第$k$远的点上(若有两个点都是第$k$远,就跳到编号小的上).问对于从每个点开始跳,跳$m$次, ...
- [洛谷P3512 [POI2010]PIL-Pilots]
题目链接: 传送门走这里 题目分析: 感觉不是很难啊--不像是蓝题(AC量也不像)恶意评分? 少打了一个+1调了半天,就这样居然还能过60pts?我思路和题解第一篇高度重合是什么鬼啊,太过分了吧本来还 ...
- 洛谷P1274-魔术数字游戏
Problem 洛谷P1274-魔术数字游戏 Accept: 118 Submit: 243Time Limit: 1000 mSec Memory Limit : 128MB Probl ...
随机推荐
- CentOs下安装图形界面
CentOS6的图形界面对计算机的内存有要求,应该是要大于512M吧,如果不满足这个条件 在安装的时候,图形界面是不会安装的,可以在linux系统安装完毕后,进入命令后再次安装图形界面 安装图形界面有 ...
- Apach配置本地域名
分三步: 一,开启虚拟域名设置,在路径中找到(apache\apache2.4.9\conf)httpd.conf 配置文件, 去掉 " Include conf/extra/httpd-v ...
- 不可靠信号SIGCHLD丢失的问题
如果采用 void sig_chld(int signo) { pid_t pid; int stat; while((pid = waitp ...
- CSU 1541 There is No Alternative (最小生成树+枚举)
题目链接:传送门 题意: 有n个点.m条边.要使n个点所有连起来且要花费最小.问有哪些边是必需要连的. 分析: 要使花费最小肯定是做最小生成树.可是题目要求哪些边是必需要用的.我们能够 这样思考,我们 ...
- Light OJ 1288 Subsets Forming Perfect Squares 高斯消元求矩阵的秩
题目来源:Light OJ 1288 Subsets Forming Perfect Squares 题意:给你n个数 选出一些数 他们的乘积是全然平方数 求有多少种方案 思路:每一个数分解因子 每隔 ...
- 用 C 语言编写一个简单的垃圾回收器
人们似乎觉得编写垃圾回收机制是非常难的,是一种仅仅有少数智者和Hans Boehm(et al)才干理解的高深魔法.我觉得编写垃圾回收最难的地方就是内存分配,这和阅读K&R所写的malloc例 ...
- 2015.04.28,外语,读书笔记-《Word Power Made Easy》 12 “如何奉承朋友” SESSION 36
1. the great and the small 拉丁词语animus(mind的意思),animus和另一个拉丁词根anima(life principle.soul.spirit),是许多单词 ...
- 【POJ 2352】 Stars
[题目链接] http://poj.org/problem?id=2352 [算法] 树状数组 注意x坐标为0的情况 [代码] #include <algorithm> #include ...
- P1726 上白泽慧音(0分)
题目描述 在幻想乡,上白泽慧音是以知识渊博闻名的老师.春雪异变导致人间之里的很多道路都被大雪堵塞,使有的学生不能顺利地到达慧音所在的村庄.因此慧音决定换一个能够聚集最多人数的村庄作为新的教学地点.人间 ...
- es6总结(二)
1.es6三种声明方式: a.var 全局声明 b.let 局部变量声明 c.const 常量声明 2.变量的解构赋值 a.数组的解构赋值 等号左边与右边形式统一 let [a,[b,c] ...