Logo
(追記) (追記ここまで)

3198번 - nagibni 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB1363100.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

힌트

출처

Olympiad > Croatian Highschool Competitions in Informatics > 2005 > National Competition #2 - Seniors 3번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /