Approach hintTry it first, then revealHide
Argue that an optimal choice never places a tourism city below an industry city, so each city has a fixed gain: its depth minus the number of its descendants. Sort the gains and take the k largest.
Argue that an optimal choice never places a tourism city below an industry city, so each city has a fixed gain: its depth minus the number of its descendants. Sort the gains and take the k largest.