Hi, I'm working on http://mirror.codeforces.com/contest/580/problem/B and getting WA on test 7.
This is my code: http://ideone.com/IlboLx
I read the tutorial and it made sense, I'm just using upper_bound() instead of my own binary search.
Any hint on the bug would be great. Thanks!
Oops I just realized the answer could overflow int. That fixed it.