Problems > Fewest Bounded Pieces > Editorial

Fewest Bounded Pieces — Solution & Editorial

Back to the Problem

Greedy left-to-right: keep extending the current piece while its sum stays ≤ K; start a new piece when it would overflow. Any element > K makes it impossible.

Complexity: O(N)