Data Structures & AlgorithmsHardCodeforces Div2 C · TCS NQT

Parcels with weights [4, 9, 2, 7, 5, 8, 3, 6] must be shipped in this order, and a ship carries a contiguous block each day. What is the smallest daily capacity that lets all parcels ship within 3 days?

  1. A. 13
  2. B. 14
  3. C. 9
  4. D. 17

Correct answer: D. 17

Binary search the capacity: each day ships a maximal prefix of the remaining parcels, and the capacity is feasible when the day count is at most D. The average load (sum/D) is a lower bound, not the answer, because parcels are indivisible and must keep their order.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic