Partition elements into exactly groups. Each group has a cost. Find the lowest total. Direct DP: states, transition = . Apply Aliens to remove dimension.
With penalty, we get DP per binary search. Still slow. Apply CHT to reduce transition to . Combined: per binary search. Total: . Multiple optimizations stack.