#P6377. [PA 2010] Termites
[PA 2010] Termites
Description
There is a sequence of length . Two players take turns. Each time, a player may choose a number that is adjacent to , gain a score equal to its value, and change it to . Find the scores of the two players if both play optimally.
Input Format
The first line contains an integer , as described in the statement.
The next line contains integers, representing the sequence.
Output Format
Output one line with two integers, representing the final scores of the two players when both play optimally.
8
1 2 0 3 7 4 0 9
17 9
Hint
Constraints
For all testdata, it is guaranteed that . For any element in , it is guaranteed that , and there is at least one .
Translated by ChatGPT 5
京公网安备 11011102002149号