Stone Game V

There are several stones arranged in a row, and each stone has an associated value given in the array stoneValue[i].

In each round, Alice divides the row into two non-empty parts (left and right), then Bob discards one part and Alice keeps the other. The round ends and the score for that round is the sum of values of the stones Alice keeps. Then the remaining part is played again.

The game ends when only one stone remains. Alice's total score is the sum of scores from all rounds. Assuming both play optimally, return the maximum score Alice can achieve.

Examples
Input: [6,2,3,4,5,5]
Output: 18
Hints

Stone Game V

There are several stones arranged in a row, and each stone has an associated value given in the array `stoneValue[i]`.