시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB622100.000%

문제

Railway network infrastructure in one country consists of a certain numbers of individual railway segments. 

Each segment connects two different towns. We know the lengths of all segments, and the network is such that between any two towns there is a unique path connecting them.

Recently, the management of the railway company decided to replace their old trains with ultramodern and fast trains imported from Japan. 

A route of a train consists of a sequence of two or more towns, with all neighboring towns on the route connected by a segment. Length of the route is defined as the sum of the lengths of all the segments included. Because trains are very fast it is not allowed that two different routes pass through the same town. 

Write a program that will determine the new routes in the network under the following restrictions: Exactly one route has to pass through each town, and sum of the lengths of all the routes should be as large as possible. 

입력

First line of input contains an integer N, 1 ≤ N ≤ 2000, the number of towns. Towns are designated with numbers from 1 to N. 

Following N-1 lines contain the descriptions of the segments. Each line contains three integers A, B and C representing a segment between town A and town B of length C, 1 ≤ C ≤ 1,000,000. 

Note: there will always exist a solution for the given test data. 

출력

First and only line of output should contain only the maximal sum from the problem statement. 

예제 입력 1

5
1 2 10
1 3 10
1 4 10
4 5 1

예제 출력 1

21

예제 입력 2

6
1 2 1
1 3 3
1 4 7
2 5 4
2 6 6

예제 출력 2

20

예제 입력 3

9
1 2 1
2 4 2
3 4 1
4 5 5
6 5 1
5 7 2
7 8 1
8 9 2

예제 출력 3

11