Lagrangian Relaxation / Aliens Trick Ladder¶
This ladder is for the exact-count optimization lane where:
- the original problem wants the best answer with exactly
Kchoices - direct DP over
Kis too slow - adding a penalty per choice makes the relaxed DP cheap
Who This Is For¶
Use this lane if:
- you already know how to write the direct exact-
KDP - the only issue is that the count dimension is too expensive
- the relaxed problem for fixed penalty becomes much simpler
This lane is intentionally narrow:
- one exact starter
- one official flagship rep
- a few official follow-ups that reuse the same worldview in different skins
Warm-Up¶
- direct exact-
KDP when constraints still allow it
Target skill:
- see the expensive count dimension before reaching for Aliens trick
Core¶
- exact starter ->
aliens-trick-nonadjacent-max.cpp - exact flagship -> Red and Blue Lamps
Target skill:
- rewrite "exactly
K" as one global penaltylambda - solve the penalized DP
- binary search
lambda - recover the original answer
Stretch¶
- sequence / day-partition follow-up -> AtCoder ABC305 Ex - Shojin
- pairing / parity follow-up -> AtCoder ABC400 G - Patisserie ABC 3
- interval-coverage / all-k follow-up -> AtCoder WTF22 Day1 D - Welcome to Tokyo!
Target skill:
- distinguish "same penalty-search worldview" from "same exact DP recurrence"
Retrieval Layer¶
- exact quick sheet -> Aliens Trick hot sheet
- exact starter ->
aliens-trick-nonadjacent-max.cpp - parent DP retrieval -> DP cheatsheet
- broader route -> DP ladders
Repo Anchors And Compare Points¶
- topic page -> Lagrangian Relaxation / Aliens Trick
- parent DP worldview -> DP Foundations
- compare split-point row optimization -> Divide and Conquer DP
- compare coordinate-function optimization -> Slope Trick
- flagship rep -> Red and Blue Lamps
The cleanest in-repo loop here is:
- learn the exact penalty-search contract from the Lagrangian Relaxation / Aliens Trick topic
- trust the starter through Red and Blue Lamps
- compare back against plain exact-
KDP and other DP optimizations so the chooser becomes real
Exit Criteria¶
You are ready to move on when:
- you can explain why the relaxed solver must return
(value, count) - you know the right tie-break direction for the maximization route
- you can binary search
lambdawithout floating-point - you can say when Aliens trick is unnecessary because direct
O(NK)DP already fits
External Practice¶
- AtCoder ABC218 H - Red and Blue Lamps
- AtCoder ABC305 Ex - Shojin
- AtCoder ABC400 G - Patisserie ABC 3
- AtCoder WTF22 Day1 D - Welcome to Tokyo!