Can you help me with this task. I think that it can be
solved with min-max search, but i can't find an example on
how to implement this algorithm.
Game
Two players are playing this game: There are n numbers (n<=128), ordered in a row.
The first player takes one number from the left or the right side.
Then the second player takes one number from the left or the right
side of the rest of the numbers.
In this way they take the numbers, until there are no numbers left. What is
the maximum sum of the numbers that the first player has taken, if the both
players are playing optimal.
input:
first line: n - the number of numbers
second lind: n numbers, of which a <= 100
output:
the maximum sum of numbers that the first player can take
Min-Max Search
Moderator: Board moderators
Nope. To win or draw this game, "thinking about parity" is enough. But the greedy algorithm doesn't guarantee that you get the maximal sum.Quantris wrote:It's actually way way simpler than DP
think about parity.
Consider the following input:
Code: Select all
8
3 0 3 0 3 0 3 10