Editorial for SAC '21 Code Challenge P2 - Littering
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 each piece of garbage you remove, iterate over the remaining elements and remove the maximum value one.
Time Complexity:
Subtask 2
Instead of looping over the entire array, we can sort it and sum up the first elements to yield the answer (remember to ensure your data types can handle numbers up to ).
Time Complexity:
Comments