树形dp
cf526D
cf511D