Editorial for DMOPC '15 Contest 6 P3 - Harvest
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.
Since we only need to know the final number of potatoes in each row after the updates, we can use a difference array of length to keep track of the number of potatoes in each row. Each column can be updated in time, making this part of the algorithm . After retrieving the actual values, we can use a two-pointer approach to find the minimum required in time. The total time complexity is therefore .
Comments