Can anyonre give me a hint how to solve this problem here! asked 30 Aug '17, 01:04

Assuming that you are familiar with segment tree You can solve this problem by building a segment tree, with a sorted subarray in every vertex and then divide [l, r] into subsegments, and do binary search on subsegments. answered 30 Aug '17, 01:19
Using sorted subarray in every vertex will take $n^2 log(n)$ time, no?? If I am getting correctly what you are saying..
(30 Aug '17, 01:28)
$\log(n)^2$ for each query
(30 Aug '17, 01:49)
no.. while creating tree itself.. Can you post some pseudo code here..??
(30 Aug '17, 01:54)
2
@kauts_kanu, this is also known as mergesort tree. But I had to use input via
(30 Aug '17, 09:00)
Did not know about this.. thanks.. :)
(30 Aug '17, 15:46)

An approach for this problem is explained here: http://codeforces.com/blog/entry/10183?#comment156355.