Keep two best values
transcript
Build a banner strip from blocks. No two neighbours may match. Keep the cheapest prefix?
Keep only the cheapest prefix. For eight slots, it finds twelve. The right answer is eleven.
The cheapest prefix ends in some width. The next block may need that very width. Then that block cannot be placed. Then the best is blocked.
Keep the cheapest cost, and its last width. Also keep the cheapest with another last width. Use it when the best clashes.
Fifty thousand slots, ten widths. That is half a million steps. Costs add up to five times ten to the thirteen. Use sixty-four bits.
Build a case where the cheapest prefix clashes with the next block. Compare with a table that keeps every end. Stop at the first difference.
Write a slow table that keeps every end. Compare it with the two-value table. They must match on every input.
The best may clash. Keep a second best. Full breakdown in the lecture.