This problem Contest Page from June Lunchtime looks to be an excellent problem on dynamic programming on trees. I am unable to figure out the solution from the editorial therefore a hint by hint solution would highly be appreciated. Also I was going through many submissions and it seems that there is a solution with dfs and segment trees as well. Would be great if someone discussed that approach as well. Thank you!
Show admin stats