Help me out in this problem


can you why it is tle;
tc is o(nlogn)

@aa1 abha ar e u there ?

Yes, let me go through your code

hey try this approach to tackle the tle

@aa1 you simply give me solution can you do one things what optimisation can be done in my code to overcome tle?

he culprit is distance which is taking O(N). Check the complexity here: http://www.cplusplus.com/reference/iterator/distance/

@aa1 there is any solution without merge sort?

you could use vectors instead of multisets