In my first submission, I used lower_bound to find the index I want to erase. In my second one, I implement the same idea using ook (order_of_key) and fbk (find_by_order) of ordered_set. My first submission resulted in TLE (time limit 2 sec) where my second submission passed on 233 ms. I don't see any algorithmic difference. Overall Complexity for Worst case O ( n * (logn) * (logn) ). Anyone can point out what I am missing or if I am wrong?
I faced the same thing when I solved CF round 450 div2 C: Remove Extra one. Using the build in lower_bound, I got TLE but got AC when I used ook.