AdvancedRating 1800
Robbing a Tree of Houses
Houses form a tree rooted at node 1, each with some money. You can't rob two houses joined by an edge. Print the most money you can take.
Input
n; the n values; then n − 1 lines 'u v'.
Output
One integer.
Sample 1
Input
5 3 2 3 3 1 1 2 1 3 2 4 3 5
Output
7
Sample 2
Input
1 7
Output
7
Output appears here