Accumulation Degree
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
Accumulation Degree
Time limit: 1 seconds
Memory limit: 512 megabytes
Problem Statement
After days of heavy rain, FJNU was flooded into an undirected tree with nodes numbered from to . The rain also formed ponds on the road making it difficult to walk. More precisely, there are roads in this tree, the -th edge connects node and node and it has a weight means there is ponding with degree on this road.
Liu Wei, the clever Peppa Pig was forced by Tai Liang to calculate the accumulation degree of this tree:
For different node and , let be the greatest weight edge in the shortest path from node to node .
Liu Wei needs to calculate .
As a full stack developer, Liu Wei has more important things to do, so you are asked to help him solve this problem.
Input
The first line contains one integers .
In the following lines, each line contains three integers $u_i,v_i,w_i(1 \leq u_i,v_i \leq N,1 \leq w_i \leq 10^7)$ denoting there is an edge between node and with a weight .
Output
Print a single integer, denoting the answer to the question.
3
1 2 10
2 3 20
50