I've been trying to solve Problem A of yesterday's finals. My solution is very similar to Tourist's solution (~33:00). My code is here. It TLEs on test case 12, but I can't seem to figure out why, I'm pretty sure the complexity is NlogN. In all likelihood, it's down to some edge case/infinite loop. If somebody could help me figure out the issue, I'd be very grateful. Thanks in advance.
lower_bound
What's the issue with lower_bound?
http://www.cplusplus.com/reference/algorithm/lower_bound/ http://www.cplusplus.com/reference/set/set/lower_bound/
That worked, thanks a lot for your help! For reference, the reason that it works is explained in a comment here:
https://codeforces.net/blog/entry/20553