luogu#P2820. 局域网
局域网
Background
In a certain local area network, there are computers. Due to negligence when setting up the LAN, the connections now form cycles. We know that if a LAN contains cycles, data will keep circulating within the cycle, causing network lag. Because the network cables connecting computers are different, some connections are not very smooth. We use to denote the smoothness between and ; a smaller value of means a smoother connection between and , and means there is no cable between and .
Problem Description
Now we need to resolve the cycle problem. We will remove some cables so that the network contains no cycles, without changing the connectivity of the original graph's nodes, and the sum of over the removed cables is maximized. Please compute this maximum value.
Input Format
The first line contains two positive integers . The next lines each contain three positive integers , indicating that there is a cable between computers and with smoothness .
Output Format
A single positive integer: the maximum value of .
5 5
1 2 8
1 3 1
1 5 3
2 4 5
3 4 2
8
Hint
Constraints: For all testdata, it is guaranteed that , .
Translated by ChatGPT 5