Block Sequence
MediumRating 1500Codeforces1-D Dynamic Programming
Approach hintTry it first, then revealHide
Let dp[i] be the fewest deletions for the suffix starting at i. Either delete a[i] for 1 + dp[i + 1], or use it as a block header covering the next a[i] elements, giving dp[i + a[i] + 1] when that fits.