= minimum cost to assign first people to first gondolas. Transition: Here = number of knowing pairs in . Precompute with D (two-dimensional) prefix sums. Naive: .
With D&C: . Work through examples by hand before coding. Understanding the pattern makes implementation simple. Practice with similar problems to reinforce your understanding.