Skip to content
playdsa
Preferences

Make yourself comfortable.

Saved on this browser. Your device’s reduced-motion preference is always respected.

Theme
Advanced settings

The Cargo Capacity

Learn
Play
Prove
Problem context and objectives
Mission briefing

Signal rescue operator · A beacon is hidden inside an ordered frequency band

Lock onto the signal without testing every frequency: The Cargo Capacity.

Each probe costs precious time; searching the wrong half moves the rescue team farther away.

How you win

  1. 1Recognize when Greedy feasibility plus answer search matches the clues
  2. 2Keep this true after every move: left excludes every impossible capacity and right remains sufficient
  3. 3Reach the result within O(n log sum weights)

Rules and pressure

  • Target cost: O(n log sum weights)
  • State rule: left excludes every impossible capacity and right remains sufficient
Lesson 1 of 3

Live algorithm trace

Greedy feasibility plus answer search

Complete execution
1 of 8

Capacity cannot be below the heaviest package or above the total weight.

1left, right = max(weights), sum(weights)
2capacity = midpoint
3greedily count required days
4if required <= days: right = capacity
5otherwise left = capacity + 1
6return left
days = 5left = 10right = 55
Truth to preserve / Cost target
Truth to preserve

left excludes every impossible capacity and right remains sufficient

Cost target

O(n log sum weights)

For a proposed capacity, greedily fill each day in order and start a new day only when the next package would overflow. Feasibility is monotonic as capacity increases.

Your call · What should guide every step of this algorithm?

Help shape PlayDSA

Something confusing, broken, or missing? Leave a quick note without leaving your lesson.

Please leave out passwords, payment details and other private information.

Page included: /

Sign in to save feedback here, or send it with your email app. Your draft stays here while you sign in.

Open email instead