結果

問題 No.1 道のショートカット
ユーザー OKCH3COOH
提出日時 2019-10-23 20:59:10
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 710 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 362,912 KB
最終ジャッジ日時 2024-07-08 05:18:38
合計ジャッジ時間 7,205 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 7 TLE * 1 -- * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

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()))

edges = [[] for _ in range(N)]

for fr, to, cost, time in zip(S, T, Y, M):
    fr -= 1
    to -= 1
    edges[fr].append((to, cost, time))

que = deque([(0, 0, 0)])
ans = float('inf')
while que:
    now, cost, time = que.popleft()

    if now == N - 1:
        ans = min(ans, time)
        continue

    for to, c, t in edges[now]:
        if c + cost > C:
            continue
        que.append((to, c + cost, time + t))

if ans == float('inf'):
    print(-1)
else:
    print(ans)
0