結果

問題 No.1 道のショートカット
ユーザー Hydru
提出日時 2021-11-11 16:59:15
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 554 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 81,768 KB
実行使用メモリ 63,232 KB
最終ジャッジ日時 2024-11-23 00:35:42
合計ジャッジ時間 3,620 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 38 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#limited_Dijkstra
import heapq
N = int(input())
C = int(input())
V = int(input())
S = list(map(int,input().split()))
T = list(map(int,input().split()))
Y = list(map(int,input().split()))
M = list(map(int,input().split()))

G=[[] for _ in range(N)]
for i in range(V):
    G[S[i]-1].append((M[i],Y[i],T[i]-1))

hq=[(0,0,0,[0]*N)]
heapq.heapify(hq)

while(hq):
    t,c,v,A=heapq.heappop(hq)
    A[v]=1
    if v==N-1:
        print(t)
        exit()
    for m,y,u in G[v]:
        if c+y<=C and A[u]==0:
            heapq.heappush(hq,(t+m,c+y,u,A))
print(-1)
0