Editorial for LCC '24 Contest 3 J5 - Bob to the Rescue!


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Author: Moonlight

Subtask 1

For 25% of the points, we can simply loop over all possible combinations to check the longest possible thickness of rope available, which will always be 1 or 2.

Subtask 2

Observation:

Since the ropes have distinct lengths, note that if you want to create any longer piece of rope, each shorter piece of rope can be used AT MOST once.

Using the above observation, we know that if we loop over all the possible combinations of ropes, we won't be overcounting or undercounting the number of possible pairs of ropes that form each specific length. We can store the number of each length of rope in an array, then find the maximum of that array.

Time complexity: O(N^2+X)


Comments

There are no comments at the moment.