T1 think a lot of things, what set up, and finally wrote a violent cut branches
T2 feel we should vigorously transformed the meaning of problems, but no ideas
T3 did not think Gaussian elimination
T1 "two-dimensional partial order" "Fenwick tree."
Is intended to solve the question is first converted to sa_r> = sa_ {l-1} && sb_r> = sb_ {l-1} of max {r- (l-1)}
Plus r> l after a three-dimensional , then the big brother on various CDQ, nb tree approach sets tree
However, since the query is max {r- (l-1)}, even if a third dimension is clearly not guaranteed, nor the updated ans
So we only have two-dimensional , and it seems very conventional idea is that one-dimensional sort, left one-dimensional array can be used to solve the tree
This question must pay attention to special sentence 0
T2 "search tree", "transformation meaning of the title" "interval DP"
Properties of binary search tree: For a node x, is necessarily a continuous or interval which lc rc configuration of all points
So in the process of achievements, for a period of sub-section in order to become a tree, it must have a root x \ in [l, r]
dp is defined difficult to write f [l] [r] represents the [l, r] after completion of the optimal contribution of a sub-tree, and then define an auxiliary array g [l] [r] represents the optimal case who is the root node
转移f[l][r]=f[l][k-1]+f[k+1][r]+sum{a[l,r]} k\in [l,r]
Considered to optimize the O (n ^ 3) stuff.
Firstly conclusion (I do not know how big brother thought)
Down to a range of k [g [l] [r-1], g [l + 1] [r]]
In fact, it proved relatively simple:
In consideration of the construction has been [[l, r-1] of the tree was added to increase the apparent point r g [l] [certain position r-1] of the right subtree
A point right subtree in this case becomes a desired optimum can only be the root into g [l] [r-1] is
Therefore k \ in [g [l] [r-1], r] Similarly have k \ in [l, g [l + 1] [r]] can take an intersection
Complexity becomes O (n ^ 2) demonstrated
Enumeration outermost section length O (n)
As long as the card under each enumeration len sum {k} complexity of O (n) to
Consider [l, r] in the range [g [l] [r-1], g [l + 1] [r]]
[L + 1] range [r + 1] is [g [l + 1] [r], g [l + 2] [r + 1]]
Found then g [l + 1] [r] is equal, is obviously up to each point twice enumerated
QED