ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1039. Anniversary Party

good dynamic problem
Posted by just_practice 8 Apr 2011 16:59
for each node v,calculate a(v)-maximum cost achieved by the subtree with root "v" in which v will attend, and n(v)-maximum cost achived by the subtree with root "v" in which v will not attend.
a(v)=p(v)+n(v1)+n(v2)+...+n(vn), vi-is the child of v.,p(v)-is the point of v itself.
n(v)=sum(max(n(vi),a(vi))),for all i-s.
and simply use DFS.
Re: good dynamic problem
Posted by hehe 29 Mar 2013 11:22
thnxxxxxxxxx