Editorial for ECOO '21 P4 - Chris' Candy
Submitting an official solution before solving the problem yourself is a bannable offence.
Authors:
,The key observation here is how many combinations a given output has. Consider the sample output grouped by type: 2 9 9 9
. The counts of the elements look like this:
2 : 1
9 : 3
Now for each element, recall that two sets with the same amount of all elements are the same. Assuming the rest of our elements have
Let us have
We subtract the empty combination here.
As an example suppose we are given
Well, since we get to choose
And indeed, the sample input has 1 2 3
, which has
This should give us the understanding to solve the first subtask. We can simply output
For the remaining subtasks, we note that we can find the sum of
and
is minimum. By making a change of variable of
and we are trying to minimize
Now consider that there exists a
The only positive integer solutions to the inequality are when
The second subtask rewards contestants who made these observations but implemented an inefficient solution, potentially by factoring in linear time.
The final subtask can be solved by factoring in
Time Complexity:
Comments