Editorial for An Animal Contest 2 P5 - Koala Carnival
Submitting an official solution before solving the problem yourself is a bannable offence.
Authors:
,Subtask 1
For each query from
Time Complexity:
Subtask 2
To optimize, we use a two pointer approach to determine
As we did before, we take the maximum of
Time Complexity:
Subtask 3
As before, we precompute
Time Complexity:
Comments
One doubt here: how do you search for duplicates? The only method I can think of is using map which consumes an additional log(N) time for each search.