Editorial for DMPG '18 G2 - Gardening Fun
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
The key idea is that when watering a subarray, do not consider the entire subarray. Instead, consider the number of times a certain plant is watered as a result of these subarrays. Let
Call
Time Complexity:
For the second subtask, we will perform an optimization so that the transition becomes
We can precompute
Time Complexity:
Comments