P3507 [POI2010]GRA-The Minima Game

    • 384通过
    • 692提交
  • 题目提供者 洛谷
  • 评测方式 云端评测
  • 标签 动态规划,动规,dp 模拟 贪心 POI 2010 高性能
  • 难度 提高+/省选-
  • 时空限制 1000ms / 128MB

题解

  • 提示:收藏到任务计划后,可在首页查看。
  • 体验新版界面

    最新讨论 显示

    推荐的相关题目 显示

    题目描述

    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.

    输入输出样例

    输入样例#1: 复制
    3
    1 3 1
    输出样例#1: 复制
    2
    提示
    标程仅供做题后或实在无思路时参考。
    请自觉、自律地使用该功能并请对自己的学习负责。
    如果发现恶意抄袭标程,将按照I类违反进行处理。