#T44. 局域网
局域网
Description
A local area network (LAN) consists of n (n ≤ 100) computers. Due to the negligence of the staff during the setup, the connections in the LAN have formed loops. We know that if loops exist in a LAN, data will continuously circulate within the loops, causing network lag. Since the network cables connecting the computers vary in quality, some connections are less smooth. We use f(i, j) to represent the smoothness of the connection between i and j (f(i, j) ≤ 1000), where a smaller f(i, j) value indicates a smoother connection between i and j. A value of 0 for f(i, j) means there is no network cable connection between i and j. Now, we need to resolve the loop issue by removing some connections, ensuring the network has no loops, and maximizing the sum of the removed connections' Σf(i, j). Please compute this maximum value.
Input Format
The first line contains two positive integers, n and k.
The following k lines each contain three positive integers i, j, and m, indicating that computers i and j are connected by a network cable with a smoothness value of m.
Output Format
A single positive integer representing the maximum value of Σf(i, j).
5 5
1 2 8
1 3 1
1 5 3
2 4 5
3 4 2
8