Pre-knowledge: only two points
Provenance
Thesis: Analysis of a class of dichotomous methods
The first time it appeared in the work of Guoji in 2012, the promotion was in 2015, and it was another algorithm invented in the Chinese national team/training team (I have to say that the development of the Chinese information competition promotes the progress of world science.
thought
Basic
WQS dichotomy, also called convex optimization, has the following limitations:
- The function is a convex function (single increase/decrease in slope)
- The maximum value and maximum point of a function (obviously a convex function) can be found in a short time
- Limit k, ask
Let's draw a picture first:
First use the convex function analysis, because the downward convex is the same.
Due to the special nature of the subject:
The maximum value and maximum value point of the function can be found in a short time
How can we use it to get it?
At time, we can change the upper convex hull in the figure above:
We found that when , the point most to the right value, when , the value of the point most to the left, the greater the greater the distance of movement, monotone
When we move the most value point to k, we can directly find the value, and then subtract it to get the required answer.
So the algorithm flow came out: divide one into two , make the most value point equal to k, and then find the corresponding most value- .
Slightly expanded
The above situation is actually rare. In most cases , it is not strictly convex. It is a monotonous slope that does not decrease/increase. In other words, the highest point in the dichotomy may constitute an interval:
In this case, if you only find a maximum point in the interval, you may never be able to make it equal to k.
Think about it, in fact, we only need to satisfy that k is in the range of the maximum value we find, so that the maximum value obtained is still equal to , and finally subtracted .
So the dichotomy becomes: divide one into two , so that the left end point of the maximum point interval is not greater than k and closest to k. Such an interval is guaranteed to contain k, and then find the corresponding maximum value- .
We only need to ensure that we can still find the minimum and minimum maximum points in a short time.
Some examples
Just mutter about the explanation of the sample problems first, and readers can see the solutions of others