Beta
Optimal Card Collection Game
Description:
Problem Statement
Alice and Bob are playing a strategic game with a stack of collectible cards, each having a certain value. The rules are as follows:
- Both players draw at least 1 card in their turn.
- Alice starts by drawing 1 card.
- In subsequent turns, both players can draw up to twice the maximum number of cards drawn in any previous turn.
- Both players aim to maximize their total value of collected cards while playing optimally.
Given the values
of all cards, determine the maximum total value of cards Alice can collect.
Input
values
: A list ofn
integers representing the values of the cards in the stack, from top to bottom.
Constraints
1 <= n <= 1000
0 <= values[i] <= 10^6
Output
- An integer representing the maximum total value of cards Alice can collect.
Example
Input 1
[10, 20, 30, 20, 50]
Output 1
60
Explanation 1
- Alice's first turn: Alice draws the top card, which has a value of 10.
- Bob's first turn: Bob can draw between 1 and 2 cards. He draws 20. His total value is now 20.
- Alice's second turn: Alice can draw between 1 and 2 cards. She draws 30 and 20. Her total value is now 10 + 30 + 20 = 60.
- Bob's second turn: Bob can draw between 1 and 4 cards. He draws 50. His total value is now 20 + 50 = 70.
Note that if Bob draws 2 cards at first, Alice will draw 3 cards in her second turn, leaving Bob less final total value of 50.
Input 2
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Output 2
24
Arrays
Games
Dynamic Programming
Similar Kata:
Stats:
Created | Oct 4, 2024 |
Published | Oct 5, 2024 |
Warriors Trained | 109 |
Total Skips | 28 |
Total Code Submissions | 46 |
Total Times Completed | 4 |
Python Completions | 4 |
JavaScript Completions | 3 |
Total Stars | 6 |
% of votes with a positive feedback rating | 100% of 2 |
Total "Very Satisfied" Votes | 2 |
Total "Somewhat Satisfied" Votes | 0 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 2 |
Average Assessed Rank | 3 kyu |
Highest Assessed Rank | 3 kyu |
Lowest Assessed Rank | 3 kyu |