Editorial for Mock CCC '26 S4 - Swing
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Subtask 1
This subtask is intended to reward brute force solutions or inefficient implementations of the intended full solution.
Subtask 2
This subtask is intended to reward incorrect greedy approaches. For example, sort the pieces of currency from
lowest to greatest, and then for each bag, greedily pick the coin with the lowest
that can fit using binary search, and repeat for each bag.
Time complexity:
Subtask 3
The intended solution is to merge coins of even denomination into larger coins until there is either or
of each coin, and merge coins of odd denomination until there is at most
of each coin. Note that after merging, all coins of denomination
and
can be placed into separate groups.
Consider the coins and
for
. Notice that after the merging of coins, the sum is at most
. Therefore, form as many possible remaining groups using this observation.
Finally, the rest of the coins can be added greedily to whichever group can hold it without exceeding a sum of due to the fact that
. The proof is left as an exercise to the reader.
Time complexity:
Comments