結果
| 問題 |
No.3111 Toll Optimization
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-18 20:41:55 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 609 bytes |
| コンパイル時間 | 672 ms |
| コンパイル使用メモリ | 82,608 KB |
| 実行使用メモリ | 117,700 KB |
| 最終ジャッジ日時 | 2025-04-18 20:42:09 |
| 合計ジャッジ時間 | 13,138 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 5 TLE * 1 -- * 64 |
ソースコード
from heapq import*
N,M,K=map(int,input().split())
gr=[[] for i in range(N)]
C=list(map(int,input().split()))
for i in range(M):
u,v=map(int,input().split())
gr[u-1].append((v-1,C[i]))
gr[v-1].append((u-1,C[i]))
dist=[[1<<60]*(K+1) for i in range(N)]
dist[0][0]=0
hq=[(0,0,0)]
while hq:
d,p,c=heappop(hq)
for np,cs in gr[p]:
if dist[np][c]>d+cs:
dist[np][c]=d+cs
heappush(hq,(d+cs,np,c))
if c!=K and dist[np][c+1]>d:
dist[np][c+1]=d
heappush(hq,(d,np,c+1))
ans=min(dist[-1])
if ans==(1<<60):
print(-1)
else:
print(ans)