how to solve this ?

Problem Link:https://www.codechef.com/problems/NPLFLB

Please Explain how to maintain the sorted order after every operation?

You need to do it with segment tree or binary indexed tree. You don’t need to sort.

Just calculate the max of all the elements at the start and keep updating the max during the queries.

1 Like