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.

Author: Riolku

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 i execs. The optimal exec to remove is of course the one with the largest t_i.

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 T, and if so, update our answer.

Alternatively, we can simply stop once the total minus the max is too large, since that quantity never decreases.


Comments

There are no comments at the moment.