#P1195. 口袋的天空

口袋的天空

Description

You are given the number of clouds NN, and then MM relations indicating which clouds can be connected.

Now Xiaoshan wants to connect all clouds into exactly KK cotton candies (connected components). Each cotton candy must use at least one cloud. He wants to know how to connect them so that the total cost is minimized.

Input Format

The first line contains three integers N,M,KN, M, K.

Each of the next MM lines contains three integers X,Y,LX, Y, L, meaning cloud XX and cloud YY can be connected at a cost of LL.

Output Format

Output one line containing a single integer, the minimum total cost.

If it is impossible to obtain exactly KK cotton candies, output No Answer.

3 1 2
1 2 1

1

Hint

Constraints:

  • For 30%30\% of the testdata, 1N1001 \le N \le 100, 1M1031 \le M \le 10^3.
  • For 100%100\% of the testdata, 1N1031 \le N \le 10^3, 1M1041 \le M \le 10^4, 1K101 \le K \le 10, 1X,YN1 \le X, Y \le N, 0L<1040 \le L < 10^4.

Translated by ChatGPT 5