Editorial for BSSPC '22 P4 - Exec Pieing
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
For this subtask, brute force all possible execs to remove from the line, and then iterate through the list to find out how many execs can be pied.
Subtask 2
For full marks, suppose we want to pie the first
Therefore, we should keep a running sum and a running max. At each step, we check if our sum minus our max is at most
Alternatively, we can simply stop once the total minus the max is too large, since that quantity never decreases.
Comments