biciklisti
This year the country of the United Union is the host of a great bicycle race. The country has n cities marked by numbers from 1 to n. The cities are connected by roads, and there is just one way to get from any city to another one. The organizers of the race decided to make the longest route possible.
Write a program that for the given network of roads finds the longest possible route for the race.
InputThe input is read from the standard input. In the first row there is a number n (2<= n <= 8000). In every n-1 rows there are integer numbers a, b, and d, which means that the cities a and b are connected with road of length d (1 <= d <= 1000).
OutputOn the standard output write just one line that contains the length of the longest route.
Input:
Output:
10
1 2 3
1 3 7
1 4 1
2 5 5
2 6 8
3 7 6
3 8 9
4 9 2
4 10 4Output:
27 Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.