Unexpected use of Binary Search ( Codeforces problem )

Video

https://www.youtube.com/watch?v=BMilsTX0CW8&t=