結果

問題 No.1 道のショートカット
ユーザー aaaaaaaaaa2230
提出日時 2021-04-05 09:55:48
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 606 bytes
コンパイル時間 473 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 71,296 KB
最終ジャッジ日時 2024-12-30 11:31:23
合計ジャッジ時間 5,918 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 36 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
n = int(input())
c = int(input())
v = int(input())
L = [list(map(int,input().split())) for i in range(4)]

e = [[] for i in range(n)]
for s,t,y,m in zip(L[0],L[1],L[2],L[3]):
    s -= 1
    t -= 1
    e[s].append((t,y,m))
    e[t].append((s,y,m))

inf = 10**10
dis = [[inf]*(c+1) for i in range(n)]
dis[0][c] = 0
q = deque([(0,c)])
while q:
    now,d = q.popleft()
    for nex,y,m in e[now]:
        if d >= y and dis[nex][d-y] > dis[now][d]+m:
            dis[nex][d-y] = dis[now][d]+m
            q.append((nex,d-y))
ans = min(dis[-1])
if ans == inf:
    ans = -1
print(ans)
0