結果

問題 No.1 道のショートカット
ユーザー OKCH3COOHOKCH3COOH
提出日時 2019-10-23 20:59:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 710 bytes
コンパイル時間 72 ms
コンパイル使用メモリ 10,952 KB
実行使用メモリ 9,164 KB
最終ジャッジ日時 2023-09-22 13:38:11
合計ジャッジ時間 7,085 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,636 KB
testcase_01 AC 20 ms
8,672 KB
testcase_02 AC 19 ms
8,572 KB
testcase_03 AC 19 ms
8,684 KB
testcase_04 AC 19 ms
8,568 KB
testcase_05 AC 18 ms
8,640 KB
testcase_06 AC 17 ms
8,644 KB
testcase_07 AC 19 ms
8,620 KB
testcase_08 AC 38 ms
9,008 KB
testcase_09 AC 21 ms
8,656 KB
testcase_10 AC 62 ms
9,164 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
権限があれば一括ダウンロードができます

ソースコード

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