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

I found the reason for me WA on 13#
Posted by fytain 25 Jul 2013 09:50
my method is DP:
//invite
int sum = 0;
for (Integer c : guest.children) {
    sum += DP[c.intValue()][0];
}
DP[index][1] = sum + RATE[index];

// do not invite
sum = 0;
for (Integer c : guest.children) {
    int max = Math.max(DP[c.intValue()][0], DP[c.intValue()][1]);
    sum += max;
}
DP[index][0] = sum;



at first, I got WA on 13#,
DP the tree should from leaf to root,
but at first I sort the guests by its children count,
the right way is sort the guests by depth

Edited by author 25.07.2013 09:50