Dynamic Programming21 sections · 916 units
Open in Course

IOI Aliens - Combined Optimization

Aliens + CHT

Step 11: Apply Aliens Trick. Add penalty λ\lambda per photo to remove the kk dimension. Now you have O(n)O(n) states instead of O(nk)O(nk). Step 22: The transition has form dpλ[i]=minp(dpλ[p]+f(p,i))dp_{\lambda}[i] = \min_p(dp_{\lambda}[p] + f(p, i)) where f(p,i)f(p, i) involves quadratic terms.

Rewrite f(p,i)f(p, i) in the form mpi+bpm_p \cdot i + b_p and apply Convex Hull Trick (from Section 1616). Final complexity: O(nlognlogC)O(n \log n \log C) where CC is the coordinate range. The Aliens Trick removes one dimension, and CHT makes the remaining transitions fast. This combination is common in advanced DP.