Binary Search , How to Crack

Problem link : CodeChef: Practical coding for everyone

Every one applying binary Search in the above problem.Can anyone explain me the logic??
How to solve this problem??

In this question the maximum answer can be (smallest +largest)/number of cars packed (it can be less But can never be greater then this) and minimum is 1. So start with a mid value=(max+min)/2. And do binary search . If the result is true increment left and other wise decrement right . Take the maximum of the answer and this will be right then .

After doing this, do this one . Uses Binary search .This will help you

http://www.iarcs.org.in/inoi/online-study-material/problems/post-election-transfers.php

Cheers

2 Likes

Welcome , ever ready to help . Thanks for upvote .

thanks @adityakhanna1999