荔园在线

荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀

[回到开始] [上一篇][下一篇]


发信人: selahx (宿醉未散,早梦半醒), 信区: ACMICPC
标  题: A GAME
发信站: 荔园晨风BBS站 (2004年10月08日16:09:20 星期五), 站内信件

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

--

         ╭―━╮
         ┃灵犀¦
         ¦一指┃
         ╰━―╯
※ 来源:·荔园晨风BBS站 bbs.szu.edu.cn·[FROM: 192.168.1.55]


[回到开始] [上一篇][下一篇]

荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店