Editorial for CCC '16 S4 - Combining Riceballs
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:
Suppose the riceballs are numbered from
Remember that no matter how you combine riceballs in an interval, after they are combined the size will always be the same.
We have the following recurrence:
To speed this up, notice that for every
Complexity:
Comments