Shortest Route with Free Tolls
You are given a directed graph with n vertices and m edges. Traversing edge i costs w_i.
You also hold k vouchers. Each time you traverse an edge you may hand in one voucher, and then that
traversal costs nothing. A voucher is used up once handed in; if the same edge is traversed twice, each
traversal needs its own voucher to be free. You do not have to use all your vouchers.
Find the minimum total cost of a walk from vertex 1 to vertex n.
Input
The first line contains three integers n, m and k (1 ≤ n ≤ 10^4, 0 ≤ m ≤ 5·10^4, 0 ≤ k ≤ 10).
Each of the next m lines contains three integers u_i, v_i and w_i (1 ≤ u_i, v_i ≤ n,
1 ≤ w_i ≤ 10^9): a directed edge from u_i to v_i with cost w_i. The graph may contain
self-loops and several edges between the same pair of vertices.
Output
Print one integer: the minimum total cost of a walk from vertex 1 to vertex n, or -1 if vertex
n cannot be reached from vertex 1.
Notes
In the first example, the cheapest route without vouchers is 1 → 2 → 4 with cost 7. With one
voucher, the route 1 → 3 → 4 costs only 1 when the edge 1 → 3 (cost 10) is free.
In the second example, the plain cheapest route 1 → 2 → 3 → 4 costs 6, and making its two most
expensive edges free leaves a cost of 1. But the direct edge 1 → 4 can be made free on its own, so
the answer is 0.
If n = 1, you are already at the destination and the answer is 0.