Showing TLE ? please help

https://ide.codingblocks.com/s/199359 thats my code

@chemant077 Since N is vary large …1 <= N <= 200000
Your N*2 code will throw TLE. Try to think in nLogn complexity and not simple iterating in second loop instead finding in log n times.

cant think of any please help

Do you know BIT/fenwick tree or segment tree? If no then i would suggest first study them and then come back to this problem.

ok just one thing are they tough? :smiley: