A Game

£神魔★判官ぃ 2022-09-19 12:25 256阅读 0赞

A Game

IOI’96 - Day 1

Consider the following two-player game played with a sequence of N positive integers (2 = N = 100) laid onto a game board. Player 1 starts the game. The players move alternately by selecting a number from either the left or the right end of the sequence. That number is then deleted from the board, and its value is added to the score of the player who selected it. A player wins if his sum is greater than his opponents.

Write a program that implements the optimal strategy. The optimal strategy yields maximum points when playing against the best possible opponent. Your program must further implement an optimal strategy for player 2.

PROGRAM NAME game1

INPUT FORMAT

Line 1 N, the size of the board

Line 2-etc N integers in the range (1..200) that are the contents of the game board, from left to right

SAMPLE INPUT (file game1.in)

6

4 7 2 9

5 2

OUTPUT FORMAT

Two space-separated integers on a line the score of Player 1 followed by the score of Player 2.

SAMPLE OUTPUT (file game1.out)

18 11

发表评论

表情:
评论列表 (有 0 条评论,256人围观)

还没有评论,来说两句吧...

相关阅读

    相关 HDU_2580 A simple stone game

    刚开始看这一题时,就知道这根本不是一道简单题(对当时没学K倍动态减法的我来说),因为前几天刚做完一道斐波那契额数列的博弈而且它仅仅是这道题k=2的一个特例而已-\_-|||。

    相关 HDU(1851) A Simple Game (博弈)

    任给N堆石子,两人轮流从任一堆中任取(每次只能取自一堆),规定每方每次最多取K颗,取最后一颗石子的一方获胜.问先取的人如何获胜? 巴什博奕和尼姆博弈的综合。 令Bi=Mi