Help required in Wormholes question

Hello, my code is giving the wrong answer in 4 test cases in Wormholes question.

Mycode -

My Approach -
I stored contests start and end time in a vector of pairs. I sorted it and I stored exiting wormholes time in a vector and sorted it too. Now I am Iterating over starting wormholes time and checking for a contest whose starting time is greater than equal to selected wormhole starting time using lower-bound and then I am checking for an exit wormhole whose time is greater than the found contest ending time here also I used lower-bound. I am unable to find why my code failing for 4 test cases.


2 1 1
3 100
4 5

Thanks man, got whats wrong.