Alice Bob continue game pile stone there stone arrange row stone associate value integer give array stonevaluealice Bob turn Alice start on player turn player 1 2 3 stone remain stone rowthe score player sum value stone take the score player 0 initiallythe objective game end high score winner player high score tie the game continue stone takenassume Alice Bob play optimallyreturn Alice Alice win Bob Bob win Tie end game score example 1input value 1237output BobExplanation Alice lose her good pile score 6 now score Bob 7 Bob winsexample 2input value 1239output AliceExplanation Alice choose pile win leave Bob negative scoreif Alice choose pile score 1 Bobs score 5 in Alice pile value 9 loseif Alice choose pile score 3 Bobs score 3 in Alice pile value 9 loseremember play optimally Alice choose scenario make winexample 3input value 1236output TieExplanation Alice win game she end game draw decide choose pile lose constraints1 stonevaluelength 5 1041000 stoneValuei 1000