Editorial for Cheerio Contest 3 P2 - Double-O-Seven


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.

Author: fireheartjerry

The general algorithm will be greedy as locally optimal options suffice.

Subtask 1 If they reload and we have ammo, we shoot. Otherwise, we reload.
If they block, we reload.
Time Complexity: \mathcal{O}(N)
Subtasks 2 and 3 We apply the same logic for blocking and reloading from subtask 1, with some additional cases.
If they shoot:
  If they have ammo, we block.
  If they do not have ammo:
    If we have ammo, we shoot.
    Else, we reload.
Time Complexity: \mathcal{O}(N)
Subtask 2 was meant to reward correct solutions with poor implementations.

Comments

There are no comments at the moment.