#P2820. 局域网

局域网

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 f(i,j)f(i,j) over the removed cables is maximized. Please compute this maximum value.

Input Format

The first line contains two positive integers n,kn, k. The next kk lines each contain three positive integers i,j,mi, j, m, indicating that there is a cable between computers ii and jj with smoothness mm.

Output Format

A single positive integer: the maximum value of f(i,j)\sum f(i,j).

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 1n1001 \le n \le 100, 1f(i,j)10001 \le f(i,j) \le 1000.

Translated by ChatGPT 5