The Code Game
All submissions for this problem are available.
Akhilesh and Ayush start playing a game. The game consists of placing 2*N coins in a row.
The denominations of coins can be anything from 0(zero) to 200.
In each turn, the player can pick either the left-most coin or the right-most coin.
The strategy is simple. At the end the one with more value of coins wins.
Akhilesh has the first turn. He being a programmer thinks of automating the process in order to beat his friend Ayush.
He makes a program that will always win if Akhilesh has the first turn, no matter what Ayush does.
You are in place of Akhilesh and have to build a similar program.
The first line consists of 'T' the number of test cases.'T' games follow.
Each game inputs N (half the number of coins) which are followed by 2*N values denoting the denominations of the coins.
The denomination values are separated by a space.
Output one line per test case - the maximum value of coins Akhilesh has.
12 45 10 18 32 86 42 102
12 19 14 15
1 <= T <= 500
1 <= N <= 100
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, GO|
Fetching successful submissions
If you are still having problems, see a sample solution here.