Editorial for OTHS Coding Competition 1 (Mock CCC) J4 - Railgun
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Subtask 1:
It is always optimal to choose to eliminate as many robots on the right side of the array as possible.
Time Complexity:
Subtask 2:
It is possible to find the damage of all combinations utilising her railgun ability times from destroying the leftmost robots times and the rightmost robots 0 times, to destroying the leftmost robots 0 times and destroying the rightmost times. We then choose the maximum out of all combinations.
Note: A dynamic programming approach will also work.
Time Complexity:
Subtask 3:
We can further optimise our idea from Subtask 2 by using a prefix-sum array or sliding window.
Time Complexity:
Comments