Roger, Jessica, and Victor held an impromptu math contest, where Roger promptly got third place (what did you expect?). The third place prize was the second-longest path in a weighted tree with
Constraints
For all subtasks:
Subtask 1 [20%]
Subtask 2 [80%]
Input Specification
The first line of input will contain
The next
Output Specification
A single integer, the length of the second-longest path in the tree.
Sample Input 1
Copy
4
1 2 1
1 3 1
1 4 1
Sample Output 1
Copy
2
Sample Input 2
Copy
5
1 2 1
2 3 1
3 4 1
4 5 1
Sample Output 2
Copy
3
Comments
This one is tough
Since the original data were weak, a new test case was added to each subtask, and all submissions were rejudged.