Prototype: implement prototype(long[] weights, int days) returning long with a direct baseline.

Final: implement solve(long[] weights, int days) with the mechanism and bounds described above. Return the smallest capacity dividing positive weights in their original order into at most days nonempty contiguous groups. Extra days may remain unused. Empty weights return zero for positive days. Reject days <= 0 or any weight <= 0. Both stages have the same observable contract. The prototype may use the simpler method; final must use the target data structure.

All methods are static members of Exercise.

Drag or use the arrow keys to resize. Home collapses the question; End collapses the editor. Enter or double-click resets the split.
Loading editor…
No results yet.

Complete the starter code, then run the checks.
Results and errors will appear here.

Java runs on this device with CheerpJ 4.3.