#P1922. 女仆咖啡厅桌游吧
女仆咖啡厅桌游吧
Description
Xiao V’s world is organized as a tree. At each node, you may build a maid cafe, a board game bar, or leave it empty. After fixing node as the root, the planning bureau requires: for every non-leaf node , let be the number of maid cafes and be the number of board game bars in its subtree (including itself). It must hold that .
The sister’s question is: what is the maximum number of maid cafes that can be placed on this tree?
Input Format
The first line contains a positive integer , the number of nodes in the world.
Lines through each contain two positive integers , , indicating that there is an edge between and .
Output Format
Output a single line with the maximum possible number of maid cafes.
5
1 2
2 3
3 4
2 5
2
Hint
Constraints
- For of the testdata, it is guaranteed that .
- For of the testdata, it is guaranteed that , .
Translated by ChatGPT 5
京公网安备 11011102002149号