Very easy

Execution time limit is 1 second

Runtime memory usage limit is 128 megabytes

The connected graph is given. Find the spanning tree of minimal weight.

The first line contains two integers n and m (1 ≤ n ≤ 20000, 0 ≤ m ≤ 100000) - the number of vertices and number of edges in a graph. Each of the next m lines describes one edge. The edge number i is given with three integers `b[i]`

, `e[i]`

and `w[i]`

(1 ≤ `b[i]`

, `e[i]`

≤ n, 0 ≤ `w[i]`

≤ 100000) - the numbers of vertices and its weight.

Graph is connected.

Print one number - the weight of the minimal spanning tree.

Input #1

Answer #1