2016.7.12.28th set of test questions (2013noip D2)

Source: Internet
Author: User

Block

The problem is relatively simple, and the positive solution is the difference sequence. There are three lines of learning God, recorded as follows:

for (int i=1;i<=n;i++)

{cin>>h[i];

if (H[i]>h[i-1]) sum+=h[i]-h[i-1];}

My personal approach is the same as the method of learning God, only to say that he is asking for a big reduction, I beg small to reduce the size of the

Ideas

It is known that the required cumulative number is subtracted from the public part by the maximum value of the public part + each successive ascending sequence minus the sum of the public part and the last height. Can imagine to build a house, repair a 1 floor, you can follow the 2 floor together repair.

Flower

First think of the inflection point, the results of two groups have not. Baffled, finally found that there are two special circumstances can not distinguish it:

For example, you write a[i]>a[i+1]&&a[i]>a[i-1] seems to be right, and solve the situation 1, but in case 2, it hangs.

The final solution is to use a single f==1 (the previous slope is negative) or 0 (the previous slope is positive) or 1 (the initial state) of course, the previous paragraph here is not a straight forward paragraph, but a previous inflection point. This way you can solve the situation 2.

Sure, you can use DP.

Puzzle

Pure BFS 70, remaining 30 card time

The positive solution is to first BFS all the spaces next to the moving points of all the cases, and save and then use SPFA.

2016.7.12.28th set of test questions (2013noip D2)

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.