Skip to main content

Practice · 2 of 3

The Fat Transition

CHALLENGE
Difficulty: advanced+25 XP

**Scenario.** dp[i] = min over j < i of dp[j] + (a[i] + b[j])² — note the square spans both i and j. n = 200000. What is the true situation? **Which approach is the best fit? The program only needs to print the letter.** **A)** Prefix-min fusion works: keep min of dp[j] + b[j] **B)** The square entangles i and j (expands to a[i]² + 2·a[i]·b[j] + b[j]²); the cross term 2·a[i]·b[j] makes the best j depend on a[i] — a Li Chao/convex-hull structure, not a plain prefix min **C)** DP is impossible here; use Dijkstra **D)** Sort by a[i] + b[j] and take the first

Back to lesson: Practice: DP Synthesis Drills