Getting wrong answer

I am doing this question from codeforces…
https://codeforces.com/problemset/problem/1345/B
I have used binary search in it…
But i don’t know where the code is wrong…
It is not showing any output…
I tried to debug myself…But couldn’t find the bug…
This is the solution…


Please look into this.
Thanks

Hey @ashishnnnnn have you watched this video https://www.youtube.com/watch?v=mB8XfACw1Zc&ab_channel=CodingBlocks as it has been discussed in detail by Mr. 𝐏𝐮𝐥𝐤𝐢𝐭 𝐂𝐡𝐡𝐚𝐛𝐫𝐚 with code too. Please have a look :smile:

I think… MY logic is right and just some mistake is there in my code…
Please onec look into my code…

I am not sure of the logic you have used in for loop of line number 38, moreover the video I have shared with you is of binary implementation only. You can directly skip to coding part and I would suggest you instead of making your search function use upperbound stl function.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.