結果

問題 No.1 道のショートカット
コンテスト
ユーザー OKCH3COOH
提出日時 2019-10-23 20:59:10
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
MLE  
実行時間 -
コード長 710 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 383 ms
コンパイル使用メモリ 20,828 KB
実行使用メモリ 687,612 KB
最終ジャッジ日時 2026-03-29 22:41:41
合計ジャッジ時間 8,048 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 7 MLE * 1 -- * 32
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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