This problem can be solve in simpler O(NsqrtN) solution, but I will describe O(NlogN) one. We will solve this problem in offline. For each x (0 ≤ x < n) we should keep all the queries that
传送门 题意 小象喜欢和数组玩。现在有一个数组 a a a,含有 n n n个正整数,记第 i i i个数为 a i a_i ai 现在有 m m m个询问,每个询问包含两个正整数 l j l_j lj和 r j ( 1 < = l j < = r j < = n ) r_j(1<=l_j<=r_j<=n) rj(1<=lj<=rj<=n),小象想知道在 l l l到 r r r之