Boboqqq said summary must write ah.
Static seeking convex hull there are two methods, one is sorted by the abscissa,
Another is to select a starting point, and then press the other point about the sort of direction at this point
The former may be resolved directly monotonically stack, but only a half ran convex hull,
The latter can be determined once a complete closure of the convex hull
There are two ways to solve the problem of dynamic convex hull, one is cdq merge sort partition +
The other is a balanced tree half slope, in fact, very easy to use set up is slow
Analyzing convexity, when a process is to compare the slope
In the first quadrant nothing issue, but to the other quadrants not quite right
So teach me skyh vector cross product, $ a × b = ax * by-ay * bx $, scalar
In the first quadrant, and it is $ k_b-k_a $ same number, it is very intuitive tools
Maximizing an expression $ F (i), but it contains the number of $ i and j is not 0 when the item,
You should consider using the convex hull (slope optimization)
$f(i)=f_1(i)+f_2(j)+f_3(i,j)$
The first regarded as constant, it is necessary to maximize the second three, we want to maintain all possible decision points become j
Form obtained by operating the following equation: $ y (j) = k (i) * x (j) + b (i) $, where b and f have to be determined symbol relationships
It is possible to maximize the maximum f / b minimization
After each j is represented as a coordinate point $ (x (j), y (j)) $,
i appears under all the circumstances, the decision point is on a certain set of convex hull j, as reflected in the $ b (X, y) $ y-axis intercept of a straight line
Then maintain the convex hull, each half $ i find the best value of $ K (i) when asked i
"Travel Planning"
And after the prefix, plus a modification operation becomes arithmetic sequence
For a full coverage interval $ [L, R] $, $ Si $ originally seeking becomes maximum seek $ Si + (i-L + 1) * q $, q is the maximum tolerance
In order to ensure the complexity, the initial $ Si $ should not be constantly changing, but should strive to make the case unchanged $ Si $ can also maintain the most value for every q
$ Ans = max (Si + i * q) -> Si = -q * i-ans $, on each asked to take to find the minimum current intercept opposite of q to the convex hull, can be used to update the point found ans
And block
"Defense construction."
Offline, the title to help save some processing border
"Buy tickets"
$f_i=f_j+p_i*(d_i-d_j)+q_i$,$f_j=(f_i-q_i-p_i*d_i)+p_i*d_j$
It can be seen to optimize the slope, if the sequence is a direct dynamic problem like convex hull
But the problem is trees, so add a chain like a stack, each recursive only changes the stack position and the position of the element,
Every time backtracking change back on the line
But there is a limit L, so monotonous stack with Fenwick tree cover, Always ask the interval and on the line
Words will not Fenwick tree can also be dotted rule. . .
Meike partition trees stats Contribution center of gravity and center of gravity of its parent chain of sub-tree of all sons, first to his father directional sub recursive tree.
"Currency exchange"
$ F (i) = max (+ A_ia_j B_ib_j) $
$b_j=-\frac{A_i}{B_i}a_j+\frac{f(i)}{B_i}$
"monster"
And currency exchange almost, but also dynamic convex hull of how to make life difficult, monotonous after sorting stack seek to just over a convex hull.
"Tata problem."