Meaning
Alice and Bob play a game that has two numbers of positive integers in length n, each time they two
You can only select one of the two ends to take away from one of the sequences. They all want to get as big as possible.
Numbers and they are smart enough to choose the best strategy each time. Alice first chooses, asks
What is the sum of the numbers that Alice eventually gets?
Ideas
This question should be regarded as the interval DP bar, you can look at the prototype of this problem:
Other rules are the same, but only a number sequence, but also can only take the left and right at each end of a number, ask how much Alice to take? (This can be done uva-10891)
Only one line of numeric sequences can use F (i, j) to indicate a sequence of numbers with a range [I,j] segment to start with, up to how many digits to take
And this problem only becomes two lines of numerical sequence, then can be on the basis of above, add two dimension
To F (i, J, K, L), which means that the first sequence is left with the interval [i,j], and the second sequence is left with the interval [k,l], how much can you take?
When faced with a state of F (I, J, K, L), you have four choices:
1. Select the leftmost number in the first row
2. Select the rightmost number in the first row
3. Select the leftmost number in the second row
4. Select the rightmost number in the second row
So, F (i, J, K, L) can be by:
F (I+1, J, K, L)
F (i, j-1, K, L)
F (i, J, K+1, L)
F (i, J, K, L-1)
These four states are transferred,
Assuming that the current state is Alice's Choice, the last state is the maximum value that Bob chooses.
In order to make Alice the final and the largest, then you have to choose the top four states of the smallest turn,
Set SUM (i, J, K, L) to represent the sums of a sequence [I,j] segment and the sum of the [k,l] segment of the second sequence.
Sum (i, J, K, L)-The last time Bob took the value is equal to Alice can get the value
F (i, J, K, L) = SUM (i, J, K, L)-
min{
F (I+1, J, K, L)
F (i, j-1, K, L)
F (i, J, K+1, L)
F (i, J, K, L-1)
}