GET THE TREATS


How to approach this problem ?

tree dp