I played with the following problem and had brute force, but could not find a suitable solution. The problem is this:
There are 2 * N cards. You and your opponent divided them (N cards to you and N). You know exactly what cards they have, and in what order they will play them.
The rules of the game are as follows: for the first N / 2 rounds, the player with the highest card wins and for the last N / 2 rounds, the person with the lowest card wins.
Given these rules and the order in which your opponents play cards there, what is the maximum amount of winnings that you can get.
Example:
You have cards: 2, 5, 6, 7. Your opponent has cards: 1, 8, 4, 3 and plays them in that order.
The maximum score you can get is 2, since you play 7 to 1, lose the 2nd and 3rd rounds, and then play 2 in the last round to win.
My ideas: divide your cards into two piles, your larger and lower numbers. Then determine the optimal match.
Pseudo-code / algorithmic ideas are welcome.
EDIT: A total of N rounds. First N / 2 rounds: win wins. Last N / 2 rounds: win the bottom card. N must be even.
algorithm graph game-theory
user3188300
source share