Now I'll show you how to rewrite the DP recurrence into CHT form. The key is recognizing that each transition can be expressed as a line equation: y = mx + b. Start with the recurrence: dp[i] = min(dp[j] + cost[j][i]).
Expand the cost function and rearrange terms so that variables depending on j are separated from variables depending on i. You'll get: dp[i] = min(slope[j] × x[i] + intercept[j]). The slope and intercept depend only on j, while x[i] depends only on i.
This separation is what makes CHT applicable. Once in this form, you maintain a convex hull of lines. Each line represents a previous state j. To compute dp[i], you query the minimum value at point x[i] on the hull. This reduces the transition cost per state significantly.