Dynamic Programming21 sections · 916 units
Open in Course

Section Recap

What we learned

You've learned the Convex Hull Trick:

1.1. When DP has linear terms mixing indices, rewrite as minj(mjxi+cj)\min_j(m_j \cdot x_i + c_j).

2.2. Each jj defines a line. You query the lower envelope at xix_i.

3.3. For sorted queries: O(n)O(n) total using a deque.

4.4. For arbitrary queries: O(nlogn)O(n \log n) using binary search or Li Chao tree. CHT doesn't need QI. It works on a completely different structure: linearity. You now have another tool for breaking through TLE. For practice, solve the problems in the problemset.