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)