Given a tree with
Input Specification
The first line contains two integers
In the following
Output Specification
The output contains an integer denoting the maximum possible minimum length of the
Sample Input 1
Copy
7 1
1 2 10
1 3 5
2 4 9
2 5 8
3 6 6
3 7 7
Sample Output 1
Copy
31
Note: the chosen path is the path from vertex 4 to vertex 7.
Sample Input 2
Copy
9 3
1 2 6
2 3 3
3 4 5
4 5 10
6 2 4
7 2 9
8 4 7
9 4 4
Sample Output 2
Copy
15
The chosen paths are the path from vertex 1 to vertex 7, vertex 6 to vertex 9, and vertex 8 to vertex 5.
Additional Samples
Additional samples can be found here.
Constraints
Test Case | Degree of vertex | ||||
---|---|---|---|---|---|
1 | No | No | Yes | ||
2 | Yes | ||||
3 | Yes | No | No | ||
4 | No | Yes | |||
5 | Yes | No | |||
6 | No | ||||
7 | Yes | ||||
8 | |||||
9 | No | Yes | Yes | ||
10 | |||||
11 | |||||
12 | No | ||||
13 | |||||
14 | |||||
15 | |||||
16 | |||||
17 | No | ||||
18 | |||||
19 | |||||
20 |
For all test cases,
Comments