1070: Card Game
Description
Alice and Bob are playing a card game. They have a deck of cards with positive integer values. They will play the game in turns. In each turn, the pla
The goal of the game is to have the highest sum of card values in their hand at the end of the game. However, there is a special rule: If the card's value on the top of the deck is equal to the sum of the last K cards taken, the pla
Write program to output the final scores of Alice and Bob. (Alice is the first person to play, if there are less than K cards taken, then no special rule should be applied)
Input
the second line contains N integers which are the value of card
Output
Sample Input Copy
8 2
5 7 12 4 6 10 16 3
Sample Output Copy
39 24
HINT
Alice takes 5
Bob takes 7
Alice skips 12 (5+7=12) and put 12 to the end of the deck (4 6 10 16 3 12 )
Bob takes 4
Alice takes 6
Bob skips 10 (16 3 12 10 )
Alice takes 16
Bob takes 3
Alice take 12
Bob takes 10
So Alice is 39 and Bob is 24