Codeforces 1290E Cartesian Tree : For each k in the range [1, n], construct a Cartesian tree using the k smallest values, and find the sum of sizes of all the subtrees in the tree.
Codeforces 1572F Stations : The i-th city can broadcast to j-th if for all k in [i, j], max{ $h_k$ } < $h_i$
Given n operations, each providing (l, r, h), place a rectangle with height h on the x-axis between l and r. Find the total perimeter of the resulting shape after each operation.
Introduction to Segment Tree Beats