問題一覧 > 通常問題

No.3111 Toll Optimization

レベル : / AI推定難易度 : 1200 / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 154
作問者 : Naru820 / テスター : kenken714 ponjuice dayo ZOI Nzt3
お気に入りにしたユーザー ProblemId : 12115 / 自分の提出
問題文最終更新日: 2025-04-18 19:36:13
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
CPCTF 2025 : PPC (順位表) の他の問題:

Problem Statement

There are $N$ towns and $M$ bridges. The $i$-th bridge connects town $u_i$ and town $v_i$, can be crossed in either direction, and costs $C_i$ yen to cross.

You have $K$ coupons. By using one coupon when crossing a bridge, you can make the toll for crossing that bridge $0$ yen.

You are currently in town $1$ and want to go to town $N$. Find the minimum toll you must pay when using the coupons optimally.

Constraints

  • $2 \leq N,M \leq 10^5$
  • $0 \leq K \leq 3$
  • $1 \leq u_i<v_i \leq N$
  • $1 \leq C_i \leq 10^9$
  • $i \neq j \Rightarrow (u_i,v_i) \neq (u_j,v_j)$

Input

The input is given from standard input in the following format.

$N\ M\ K$
$C_1\ C_2\ldots\ C_M$
$u_1\ v_1$
$u_2\ v_2$
$\vdots$
$u_M\ v_M$

Output

Print on one line the minimum toll required to reach town $N$. However, if town $N$ cannot be reached, print $-1$. End the output with a newline.

Sample

Sample 1
Input
3 2 1
4 2 
1 2
2 3
Output
2

By moving as follows, you can reach town $N$ for 2 yen.

  • Move from town $1$ to $2$ using a coupon.
  • Move from town $2$ to $3$ without using a coupon.

It can be proved that there is no way to reach town $N$ for less than $2$ yen, so the answer is $2$.

Sample 2
Input
5 4 2
4 2 3 9 
1 2
2 3
1 3
4 5
Output
-1

Town $N$ cannot be reached.

Sample 3
Input
7 10 1
565731850 55598766 527171038 341219331 325504904 409516626 583498624 3987342 112468674 114000403
1 4
1 5
1 6
2 3
2 4
3 4
3 5
5 7
5 6
6 7
Output
3987342

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。