Dynamic Programming21 sections · 916 units
Open in Course

Section Recap

What we learned

You learned the Aliens Trick for "exactly KK" constraints:

1.1. Add penalty λ\lambda per item/segment to remove the KK dimension.

2.2. Binary search on λ\lambda to hit exactly KK items.

3.3. Verify convexity: marginal benefit must decrease.

4.4. Track counts during DP to guide binary search. You solved four problems: Building a Tall Barn (clearest convexity), Levels and Regions (standard partition), Gosha is Hunting (two constraints), and IOI 2016 Aliens (combined with CHT). This technique is rare but effective when it applies.