Determine if it’s possible to select 5 problems with required difficulties for a Cook-Off, given a list of N problems with known difficulties.

QUICK EXPLANATION

Straightforward - check the given conditions.

EXPLANATION

As the easiest problem in this contest, there isn’t much to be said about its solution.

Notice that there are no overlaps among the difficulties required for the 5 problems, so we can just independently check for each problem if at least one of the required difficulties for it appears among the input strings.

We don’t even need to remember all the input strings - it’s enough to remember how many times each of them appeared in the input. That makes checking the required conditions even easier.

Time complexity: O(N). Memory complexity: O(1).

CHALLENGE

Too easy? You can think about how this problem could be generalised. An arbitrary number of difficulties, arbitrary lists of allowed difficulties for each spot, upper or lower bounds on the total number of used problems of each difficulty, etc…

The problem statement says we should check for exactly one cakewalk, one simple,one easy
But the editorial solution works for the cases even when there is more than one cakewalk or simple or easy…!

The contest must contain exactly one. You have to choose contest problems from the list given. You have to make sure that from the list of problems, you choose exactly one of them. Hope that clears!

It is because we then have a choice for selecting the question and we have atleast one of them . In the contest we have to choose exactly one . It doesn’t matter if that question is the only one in the pool or one among many .