結果
問題 |
No.1 道のショートカット
|
ユーザー |
![]() |
提出日時 | 2021-10-30 02:17:51 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 641 bytes |
コンパイル時間 | 182 ms |
コンパイル使用メモリ | 81,916 KB |
実行使用メモリ | 76,756 KB |
最終ジャッジ日時 | 2024-10-07 13:17:17 |
合計ジャッジ時間 | 3,685 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 36 WA * 4 |
ソースコード
n = int(input()) c = int(input()) a = 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())) edge = [[] for i in range(n)] for i in range(a): s, t, y, m = S[i], T[i], Y[i], M[i] s, t = s-1, t-1 edge[s].append((y, m, t)) edge[t].append((y, m, s)) INF = 10**18 import heapq hq = [(0, 0, 0)] heapq.heapify(hq) while hq: time, cost, v = heapq.heappop(hq) if v == n-1: print(time) exit() for y, m, u in edge[v]: if cost+y <= c: heapq.heappush(hq, (time+m, cost+y, u)) print(-1)