#1342
Diamond II
Journey from Petersburg to Moscow
시간 제한
3s
메모리 제한
512MB
제출
8
정답
2
맞힌 사람
2
정답 비율
25.0%

문제

To conduct The World Programming Cup 2112 a network of wonderful toll roads was build in European part of Russia. This network consists of mm bidirectional roads that connect nn cities. Each road connects exactly two distinct cities, no two roads connect the same pair of cities, and it is possible to travel from any city to any other city using only this road network. Moreover, to ease the process of charging, no two roads intersect outside of the cities.

Each road is assigned some individual positive cost. Normally, if a driver makes a trip using some of these toll roads, at the end of his journey he would be charged the total cost equal to the sum of individual costs of all roads he has used. To increase the popularity of car travels between two capitals, the operator company Radishchev Inc introduced a special offer: make a journey from Saint Petersburg to Moscow and pay for only kk most expensive roads along your path.

Formally, let some path consists of ll roads. Denote as c1c_1 the cost of the most expensive road along this path, as c2c_2 the second most expensive and so on. Thus, we have a sequence c1c2c3clc_1 \geq c_2 \geq c_3 \geq \ldots \geq c_l of individual costs of all roads along the chosen path. If lkl \leq k, then the path is too short and the driver pays the sum of all individual costs as usual, i.e. i=1lci\sum_{i = 1}^{l} c_i. If l>kl > k, then the driver only pays for kk most expensive roads, that is i=1kci\sum_{i = 1}^{k} c_i.

As the chief analyst of Radishchev Inc you were assigned a task to compute the cheapest possible journey from Saint Petersburg to Moscow.

입력

The first line of the input contains three integers nn, mm and kk (2n30002 \leq n \leq 3000, 1m30001 \leq m \leq 3000, 1k<n1 \leq k < n) — the number of cities, the number of roads in the road network, and the maximum number of roads that one should pay for in a single journey.

Next mm lines contain description of roads. Each road description contains three integers uiu_i, viv_i, and wiw_i (1ui,vin1 \leq u_i, v_i \leq n, uiviu_i \ne v_i, 1wi1091 \leq w_i \leq 10^9) — the ii-th bidirectional road that connects cities uiu_i and viv_i with the cost of wiw_i for any direction. It is guaranteed that there is at most one road between each pair of cities and it is possible to get from any city to any other city using only these roads.

출력

Print one integer equal to the minimum possible cost of travel from the city number 11 (Saint Petersburg) to the city number nn (Moscow).

예제 입력 1

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

예제 출력 1

14

예제 입력 2

5 5 3
2 1 1
3 2 1
4 3 1
4 5 1
1 5 2

예제 출력 2

2
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
#순위사용자언어시간메모리코드 길이
8707🥇
안우진
PyPy1818ms66588KB745B
8694🥈
조서현
PyPy1885ms66888KB678B
난이도 투표
Diamond II2명 투표· 4일 전
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
#사용자문제결과언어시간메모리코드 길이제출 시간
8707
맞았습니다
PyPy1818ms66588KB745B2026. 06. 01. 14:30
8706
틀렸습니다
PyPy--739B2026. 06. 01. 14:26
8705
틀렸습니다
PyPy--821B2026. 06. 01. 14:10
8704
틀렸습니다
PyPy--744B2026. 06. 01. 14:07
8694
맞았습니다
PyPy1885ms66888KB678B2026. 06. 01. 11:34
8689
틀렸습니다
PyPy--752B2026. 06. 01. 10:42
8688
틀렸습니다
PyPy--756B2026. 06. 01. 10:40
8687
틀렸습니다
PyPy--650B2026. 06. 01. 10:36