Title Link: http://www.lydsy.com/JudgeOnline/problem.php?id=4709
I am so weak ah qaq, online dalao of the key to see not understand ah, toss a few hours, a little understand.
The naïve DP equation must be exited first.
The ① topic says that each time you pick from the left and right side of the sequence, but I don't know what will happen if you do exactly what the topic says. In fact , it is clear that no matter how it is taken, the final answer is only related to which intervals are divided. So you might want to start at the left end.
② If an interval is taken, the size of the first shell of the interval is different from the size of the last shell, then it is clear that the first or last shell is removed, and the other interval is added to the answer, and the answer to the chosen interval itself will not change. So every time we take an interval can be greedy to take, so that the first shell and the last shell size must be the same.
With these two criteria the equation is easy to come out of $ $f [i]=max\{f[j-1]+a[i]* (s[i]-s[j]+1) ^2\}$$
Where $s[i]$ indicates the number of occurrences of $a[i]$ until the number of $i$
To be Continued ...
[BZOJ4709] [JSOI2011] Lemon decision monotonicity optimization DP