Instead of choosing every carpet's position, consider the carpet laid first: it lies below every other carpet.
Suppose this is carpet , and its visible section is . No other carpet can intersect this section. Any such carpet would lie above carpet and hide it there.
Each other carpet is a single interval, so it lies entirely to the left or entirely to the right of . Its required visible position determines which side:
Moreover, each side is a valid display by itself. Every point on that side already shows one of its own carpets, so removing carpet does not uncover a gap.
This suggests an interval state. Let be the minimum corridor length for displaying carpets in that order. Define when .
If carpet is the lowest carpet of this subproblem, write and . Any such display has length at least
The whole carpet must fit, giving the first bound. Its two sides need at least and units, and its own visible section needs at least one unit, giving the second.
The remaining question is whether these two bounds are enough.