Lunchtime with Fenwick Tree
ABSNX - Absolute Min Max
Got the idea while solving, but the core technique used was to find - “Number of elements greater than some number $k$ in a given range $[l,r]$”. For this, merge-sort tree can be used getting $[l,r]$ range in sorted order and doing binary search $O(n\log^2{}n)$ which apparently won’t pass Time Limit. Hence another (new) idea was to use Fenwick Tree (with offline queries) with $O(n\log{}n)$ complexity. Main idea: consider the numbers in increasing order. All zeroes initially, and one by one raise the cutoff " while updating value in segtree “.
- Similar concept: SPOJ-KQUERY