Editorial for LCC '21 Contest 1 J5 - Penelope's Pumpkins
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.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
For the first and second subtask, a simple greedy method can be used to search for which pumpkins Penelope should take home which would give the minimum cost.
For the third subtask, a brute-force method can be used to search for which pumpkins Penelope can take home and finding the minimum cost out of all combinations.
For the full solution, if Penelope places a pumpkin of type at indexes , , and so on, assuming is divisible by , she can place each type of pumpkin up to a maximum of times. If is not divisible by , she can place pumpkins 1 more time. Greedily search for the smallest values, without taking pumpkins of a single type more than times and the remaining pumpkins of a single type more than times.
Comments