Getting runtime error repeatedly…Is it because of memory limit exceeded?? Or an invalid memory access(arrayindex out of bound exception) ??
BTW, the approach I used here is -
A segment tree where each node stores an sorted interval.
For a query i then join different disjoint intervals and then i perform a binary search over the newly formed interval to get number of elements which are greater than k.
I think Segment Tree will get TLE for this problems. I try to solve by Fenwick Tree and got AC. I think because of CPU which is used to judge that problem.