Editorial for SCC25 Contest 1 P1 - Candy Capacity


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: totallyAugustus

Subtask 1 [30%]

Since \(K = 1\), the minimum and maximum number of candies are the smallest and largest bags, respectively.

Time Complexity: \(O(N)\)

Subtask 2 [70%]

The minimum and maximum number of candies are the sum of the \(K\) smallest and largest bags. Sorting the bags by capacity suffices.

Time Complexity: \(O(N \text{ log}N)\)


Comments

There are no comments at the moment.