Editorial for An Animal Contest 3 P4 - Monkey Mayhem
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Note that any collision between any pair of monkeys is going to be at a single, distinct cell at only one possible moment in time. If the monkey on the leftmost column is at row
If monkey
We can then observe that over all distinct values of
Implementation can be done using a map to count occurrences, resulting in a log factor. There is also another solution involving sorting.
Time Complexity:
Additional Notes
Big thanks to
for suggesting this problem.
Comments