#d11304. 最大化深度和
最大化深度和
Maximize Sum of Depths
Problem Description
Given a tree with nodes, find a node to serve as the root such that the sum of the depths of all nodes is maximized. Output that maximum sum of depths.
Note: the depth of the root is .
Input Format
The first line contains an integer , the number of nodes in the tree.
The following lines each contain two integers , indicating an edge connecting and .
Output Format
Output one positive integer: the maximum sum of depths.
Sample Input
8
1 4
5 6
4 5
6 7
6 8
2 4
3 4
Sample Output
28
Constraints
. That is, an empty tree may exist.
, and the given edges are guaranteed to form a tree.