You prove it about the problem, not by looking at the data: if x works, must x + 1 also work? A bigger hold is never worse than a smaller one, so ship capacity passes the test. Questions phrased with 'exactly' usually fail it - 'do these packages take exactly 5 days' is false at small capacities, true across a band of them, then false again once a bigger hold finishes sooner. That predicate flips twice, and halving on it can discard the band that holds the answer and still return a plausible looking number. Note too that the weights array is never sorted. The sorted thing is the range of capacities, which exists only in lo and hi.