Binary-search the per-item penalty λ until the tangent point's k equals the target k, then recover opt(k) = f(λ) − λ·k.
λ=50
| Step | Cost |
|---|---|
| One penalized DP f(λ) | O(DP_cost) |
| Binary search on λ | O(log range) |
| Aliens total | O(log range · DP_cost) |
| Naive (count dimension) | O(k · DP_cost) |
| Recovery f(λ) − λ·k | O(1) |