Problem Link: https://codeforces.me/edu/course/2/lesson/6/2/practice/contest/283932/problem/A
Accepted Code
Not Accepted Code
The only change in the two code is the value being assigned to l, when i normally implement binary search i use it like in the not accepted one but why in this problem its giving wrong answer?








Auto comment: topic has been updated by coder__12345 (previous revision, new revision, compare).
First code finds point where isfit changes 'sign', if isfit(l) before running BS was = false you don't need to check it anymore, answer is always r. Second code is kind of mix with no clear idea behind it. It should work after changing to
while r>l, but 1st is just a lot better concept.btw
mid = (l+r)/2saves some keystrokes.