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(nlog2n) which apparently won’t pass Time Limit. Hence another (new) idea was to use Fenwick Tree (with offline queries) with O(nlogn) 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