I was doing the question [problem:1372498B]. Here are my two submissions [submission:271307925] and [submission:271307851]. One of the approaches works correctly while other gives TLE. The only difference between them is how I initialize the iterator 'it' using the upper_bound function.