Longest path in a tree
Very easy
Execution time limit is 2 seconds
Runtime memory usage limit is 128 megabytes
Undirected weighted tree is given. Find the length of the longest path. Find two vertices the distance between which is maximum.
Input
The first line contains the number of vertices in the tree . The next lines describe the edges. Each line contains three integers: numbers of vertices connected with an edge (vertices are numbered from to ) and the weight of an edge.
Output
Print the length of the longest path.
Examples
Input #1
Answer #1
Submissions 1K
Acceptance rate 43%