#t535. 局域网
局域网
Local Area Network
Problem Background
Special for beginners, ^_^
Problem Description
There are () computers in a local area network. Due to carelessness when the network was built, the connections inside the LAN now form cycles. We know that if the LAN forms a cycle, data will keep circulating inside the cycle, causing the network to lag. Because the network cables connecting the computers are different, some connections are not very smooth. We use to denote the smoothness of the connection between and (); the smaller the value of , the smoother the connection between and , and means there is no cable connecting and .
Now we need to solve the cycle problem: we will remove some cables so that there is no cycle in the network, and the sum of the removed cables is maximized. Find this maximum value.
Input Format
The first line contains two positive integers and .
The following lines each contain three positive integers , meaning computers and are connected by a cable with smoothness .
Output Format
One positive integer: the maximum value of .
Sample Input
5 5
1 2 8
1 3 1
1 5 3
2 4 5
3 4 2
Sample Output
8
Constraints
Time limit: 1s; memory limit: 1024 KiB for each test case.