P2734 [IOI 1996 / USACO3.3] A Game
Background
There is a two-player game as follows: a sequence of $N\ (2 \leq N \leq 100)$ positive integers is placed on a game platform. Starting with the first player, the two players take turns picking one number from either end of the sequence. After picking, the number is removed from the sequence and added to the picker’s score. When all numbers have been taken, the game ends. The player with the higher final score wins.
Description
Write a program that plays optimally to compute the final scores. An optimal strategy is one that, when facing the best possible opponent, gives the player the maximum total score possible in the current situation. Your program should always apply the optimal strategy for both players.
Input Format
The first line: a positive integer $N$, indicating the number of positive integers in the sequence.
From the second line to the end: $N$ space-separated positive integers (each in $1 \sim 200$).
Output Format
A single line with two integers separated by a space: the final scores of the first player and the second player, in that order.
Explanation/Hint
Problem translation sourced from NOCOW.
Translated by ChatGPT 5