문제
Bessie and Elsie have discovered a row of cakes cakes, with sizes in that order ().
Each cow wants to eat as much as possible. However, being very civilized cows, they decided to play a game to split it! The game proceeds with both cows alternating turns. Each turn consists of one of the following:
Bessie chooses two adjacent cakes and stacks them, creating a new cake with the sum of the sizes.Elsie chooses either the leftmost or rightmost cake and puts it in her stash.
When only one cake remains, Bessie eats it, and Elsie eats all cakes in her stash. If both cows play optimally to maximize the amount of cake they eat and Bessie plays first, how much cake will each cow eat?
입력
Each input consists of () independent test cases. It is guaranteed that the sum of all within an input does not exceed .
Each test case is formatted as follows. The first line contains . The next line contains space-separated integers, .
출력
For each test case, output a line containing and , representing the amounts of cake Bessie and Elsie respectively will consume if both cows play optimally.
예제 입력 1
2
4
40 30 20 10
4
10 20 30 40
예제 출력 1
60 40
60 40
점수
Input 2: All are equal.Input 3: Inputs 4-7: Inputs 8-11: No additional constraints.
코드를 제출하려면 로그인이 필요합니다.
로그인