[BZOJ4709] [JSOI2011] Lemon decision monotonicity optimization DP

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.