Editorial for COCI '22 Contest 4 #1 7Krokods
Submitting an official solution before solving the problem yourself is a bannable offence.
In the first subtask, Paula has no crocodile cards, so we only need to compute the score as described in the task statement.
In the second subtask, Paula has one crocodile card. We can try replacing the card with each of the letters d
, k
, o
, and r
, calculate the score for each, and then output the maximum among the scores.
In the third subtask, Paula can have up to crocodile cards. We want to try all possible combinations of replacing crocodile cards, i.e. we want to find all combinations of numbers such that , where is the number of crocodile cards. Since is only up to , we can try all combinations with nested loops, each going from to , and each representing the number of crocodile cards that will be replaced with a certain letter. For each combination, we will check if their sum isn't bigger than , and then calculate the score. As in the second subtask, we will output the maximum among the scores.
Comments