Skip to content

flexible

bradendubois edited this page Nov 24, 2021 · 9 revisions

Flexible Spaces

ID: flexible

Difficulty: 1.8

CPU Time: 1 second

Memory: 1024 MB

Solution

For this, keep two sets, one for the partition points noted at any given point, and the other for all the unique widths (a set to avoid duplicates). When reading a given partition, add the following: unit 0 up to this partition point, the complementary distance of W - partition, and the difference between this partition and each respective partition read so far. As well, consider the case of the room with no partitions. After adding all these to the set, move all of it to a list, sort that list in ascending order, and output it.

Clone this wiki locally