Infected Tree
MediumRating 1600CodeforcesAdvanced Trees (BST, LCA, Tree DP)
Approach hintTry it first, then revealHide
When a vertex becomes infected, the best move is to delete one of its children, saving that child's subtree minus the child itself, while the infection moves into the other child. Turn this into a DP over subtree sizes.