Communication Lines


Submit solution

Points: 1
Time limit: 2.0s
Memory limit: 256M

Problem type
Allowed languages
Python

Problem Description

In the suburbs, there are N communication base stations and P bidirectional cables. The i-th cable connects base stations Ai and Bi.

Specifically, base station 1 is the main station of the telecommunications company, and base station N is located on a farm.

Now, the farm owner wants to upgrade the communication lines. Upgrading the i-th cable costs Li.

The telephone company is running a promotion.

The farm owner can choose a path from base station 1 to base station N and select at most K cables on that path to be upgraded for free by the telephone company.

The farm owner only needs to pay for the most expensive upgrade cost among the remaining cables on the chosen path.

Determine the minimum amount of money required to complete the upgrade.

Input Format
Line 1: Three integers N, P, K.
Lines 2 to P+1: Line i+1 contains three integers Ai, Bi, Li.

Output Format
Output an integer representing the minimum cost.

If there is no path between base station 1 and base station N, output -1.

Data Range
0 ≤ K < N ≤ 1000
1 ≤ P ≤ 10000
1 ≤ Li ≤ 1000000

Input Sample:

5 7 1
1 2 5
3 1 4
2 4 8
3 2 3
5 2 9
3 4 7
4 5 6

Output Sample:

4

Comments

There are no comments at the moment.