

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 点
問題文
ある地方に、 から の番号がついた 個の街と、 から の番号がついた 本の道路があります。
番目の道路は街 と街 を双方向に結び、長さは です。
好きな街からスタートして同じ街を二度以上通らずに別の街へ移動するときの、通る道路の長さの和としてありえる最大値を求めてください。
制約
- は相異なる
- 入力は全て整数である
入力
入力は以下の形式で標準入力から与えられる。
出力
答えを出力せよ。
入力例 1Copy
4 4 1 2 1 2 3 10 1 3 100 1 4 1000
出力例 1Copy
1110
と移動すると、通る道路の長さの和は となります。
入力例 2Copy
10 1 5 9 1
出力例 2Copy
1
道路と繋がっていない街が存在するかもしれません。
入力例 3Copy
10 13 1 2 1 1 10 1 2 3 1 3 4 4 4 7 2 4 8 1 5 8 1 5 9 3 6 8 1 6 9 5 7 8 1 7 9 4 9 10 3
出力例 3Copy
20
Score : points
Problem Statement
A region has towns numbered to , and roads numbered to .
The -th road connects town and town bidirectionally with length .
Find the maximum possible total length of the roads you traverse when starting from a town of your choice and getting to another town without passing through the same town more than once.
Constraints
- The pairs are distinct.
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1Copy
4 4 1 2 1 2 3 10 1 3 100 1 4 1000
Sample Output 1Copy
1110
If you travel as , the total length of the roads you traverse is .
Sample Input 2Copy
10 1 5 9 1
Sample Output 2Copy
1
There may be a town that is not connected to a road.
Sample Input 3Copy
10 13 1 2 1 1 10 1 2 3 1 3 4 4 4 7 2 4 8 1 5 8 1 5 9 3 6 8 1 6 9 5 7 8 1 7 9 4 9 10 3
Sample Output 3Copy
20