Professor Rockdu is interested in tree problems, and recently he has created a new data structure called
Rock Tree.
Given a constant number $k$ and a tree $T=\{V, E\}$ with $V$ as the node set and $E$ as the edge set, a non-empty set of nodes $A$ is called a
Rock Tree of $T$ if and only if
- $A\subseteq V$
- All nodes of $A$ are connected in $T$, which means for every pair of nodes $u$ and $v$ which are both in $A$, the nodes in the shortest path between $u$ and $v$ in $T$ are all in $A$.
- The largest distance over every two nodes in $A$ is not greater than $k$. The distance between two nodes $u$ and $v$ is defined as the number of nodes (including $u$ and $v$) in the shortest path between $u$ and $v$ in the tree.
Now Rockdu makes a tree $R$ with $n$ nodes and each node $i$ has a value $a_i$ assigned to it. He wants to find the
Rock Tree with the maximum sum of node values.