CHANOQ - Editorial

Dont use the pointers (* operator for value referencing), instead use only arrays (see the tester’s code for implementation details). Or, you can also using segment trees instead of persistent segment tree.

Persistent Segment Trees @ https://blog.anudeep2011.com/persistent-segment-trees-explained-with-spoj-problems/

@lovemaydie How did you do preprocessing of points to decide which intervals a point belong ?

@vivek_shah98 Your solution has a complexity O(n * q) which will give a TLE. We perform your solution only for q1 fraction of total queries q whose number of points are greater then parameter S given in above solution. Sum of m over all queries is O(n), so O(q1 * S) = O(n) which gives q1 as O(sqrt(n * log(n))). So complexity of your solution for fraction of queries will be O(q1 * n) = O(n * sqrt(n * log(n))). For other fraction of queries we cannot upperbound their count.

@jh0n_12358 I posted a comment for clarification, but codechef removes all the newlines, spaces and tab indentations.
So please look at the screenshot here

I understood the editorial but how did arrive at the parameter \sqrt{(n/logn)} what is derivation?

I solved this problem using bitset in contest time.
https://paste.ubuntu.com/p/sZSB6rDsyQ/