#P6142. [USACO20FEB] Delegation P
[USACO20FEB] Delegation P
Description
Farmer John has pastures. These pastures are connected by roads, forming a tree.
However, after 28 years of running the farm (translator’s note: USACO was founded in 1992), FJ feels that dealing with tree problems is very difficult. He believes problems on paths are simpler.
So he decides to split the whole tree into several paths, and give the management of each path to a worker. He does not care about the number of paths, but he cares about their lengths. He wants all paths in the partition to be as long as possible, so that no one can get by using an inefficient algorithm.
FJ now wants to know the largest positive integer such that the entire tree can be partitioned into several paths, and the length of each path is at least .
Input Format
The first line contains an integer ().
The next lines each contain two integers (), describing a road connecting and .
Output Format
Output .
8
1 2
1 3
1 4
4 5
1 6
6 7
7 8
3
Hint
Sample Explanation
One possible partition is:
Subtasks
- Test points satisfy that at most one node has degree greater than .
- Test points satisfy .
- Test points have no special constraints.
Translated by ChatGPT 5
京公网安备 11011102002149号