10169_AGame

2022-5-16 18:16| 发布者: Hocassian| 查看: 71| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-3-89504623871199-Problem List-采集的数据-后羿采集器.html

Pro.ID

10169

Title

A Game

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=10169

AC

17

Submit

26

Ratio

65.38%

时间&空间限制

  • Time Limit: 1000/500 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    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.

    输入

    Multiply test cases. For each case:

    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

    输出

    Description

    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.

    Input

    Multiply test cases. For each case:

    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

    Output

    For each case, output two space-separated integers on a line: the score of Player 1 followed by the score of Player 2.

    Sample Input

    6
    4 7 2 9
    5 2

    Sample Output

    18 11

    Source

    样例输入

    6
    4 7 2 9
    5 2

    样例输出

    18 11

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部