Binary search question

closed account (1vf9z8AR)
Question-
https://www.hackerearth.com/practice/algorithms/searching/binary-search/practice-problems/algorithm/promotion-1/description/


Anyone can help me proceed with this question? I am not able to figure out how to do it. I can do it for the case when all the boxes are smaller than all the trucks.

It's a binary search problem.

Last edited on
1<=n,m<=10000
that's quite small so you may simulate the travels
put in each truck the biggest box that it may transport.
> I can do it for the case when all the boxes are smaller than all the trucks.
So what happens when you have exactly 1 box in all your boxes which is larger than the capacity of the smallest truck?

Create a very small test case, say 2 trucks and 3 boxes, where the larger truck is the one which has to make the 2nd trip, and follow what happens in your code.

Being able to analyse what happens on the edge cases is where you learn how to solve the problem completely.


> Anyone can help me proceed with this question?
http://www.catb.org/esr/faqs/smart-questions.html#prune
Topic archived. No new replies allowed.