Dynamic Programming21 sections · 916 units
Open in Course

Codeforces 321E Ciel and Gondola - Problem Statement

Codeforces 321E

There are nn people in a queue for kk gondolas. Some pairs know each other. If two people who know each other share a gondola, they talk (cost 11). Assign people to gondolas in queue order to reduce total talking. Each gondola needs at least one person.

This is partitioning: split nn people into kk contiguous groups, reducing sum of pair-costs within groups. Before reading the solution, try to identify the base case and recursive relationship yourself.