洛谷 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 ...
随机推荐
- nodejs-EventEmitter
addListener(event, listener)为指定事件添加一个监听器到监听器数组的尾部. on(event, listener)为指定事件注册一个监听器,接受一个字符串 event 和一个 ...
- c# DataTable to Object Mapping
public static class DataTableExtensions { public static IList<T> ToList<T>(this DataTabl ...
- angularjs1-3,$apply,$watch
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...
- dnscat使用——整体感觉这个工具不完善,失败率很高,传文件时候没有完整性校验,我自己测试时通过域名转发失败,可能是其特征过于明显导致
git clone https://github.com/iagox86/nbtool make 然后就可以按照下面的官方说明进行操作了. 我的感受:整体感觉这个工具不完善,失败率很高,传文件时候没有 ...
- checkbox的使用总结
1 checkbox如何选中时显示内容,不被选中时隐藏内容 <!DOCTYPE html> <html> <head> <meta name="vi ...
- c# post方式请求java form表单api
using System; using System.Collections.Generic; using System.Net.Http; namespace ConsoleApplication1 ...
- Kylin基础教程(二)
近期先把Kylin教程整理完毕,后续根据大家需求(可能会发起投票),整理其他技术栈知识教程. OK,那么接上一篇文章,感性认知了Kylin之后,我们先来看一下如何部署Kylin吧. 序号也依然沿用上一 ...
- CSS3渐变知识的介绍
渐变是CSS3当中比较丰富多彩的一个特性,通过渐变我们可以实现许多炫丽的效果,有效的减少图片的使用数量,并且具有很强的适应性和可扩展性. 可分为线性渐变.径向渐变 1 线性渐变 linear-g ...
- web_测试用例注意点
测试是一种思维,包括情感思维和智力思维,情感思维主要体现在一句俗语:思想决定行动上(要怀疑一切),智力思维主要体现在测试用例的设计上.具有了这样的思想,就会找出更多的bug.(^_^个人认为,不代表官 ...
- Pyhton学习——Day7
##############################################匿名函数################################################## ...