Editorial for DMOPC '17 Contest 4 P4 - Cops and Robbers
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
For the first subtask, choose the unassigned bank guarded for the most unassigned days and rob it on an unassigned day when it is unguarded. Continue repeating this process until all banks have been robbed. This greedy algorithm will always find a solution as long as a single bank isn't guarded every day, in which case the program should output
Time Complexity:
For the second subtask, there are two approaches. The first is to use a priority queue and set to implement the
For the second approach, let
For example, if the input is:
6
2 1 4 2 1 1
then
2 1 1 2 4 1
1 4 ? ? 2 ?
Then we fill the question marks with the remaining banks.
2 1 1 2 4 1
1 4 3 5 2 6
Time Complexity:
Comments
What does |S| mean in this context?