結果

問題 No.1 道のショートカット
ユーザー C++ C++
提出日時 2024-02-20 17:34:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 64 ms / 5,000 ms
コード長 673 bytes
コンパイル時間 419 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 68,628 KB
最終ジャッジ日時 2024-02-20 17:34:42
合計ジャッジ時間 4,077 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
55,608 KB
testcase_01 AC 35 ms
55,608 KB
testcase_02 AC 40 ms
55,608 KB
testcase_03 AC 39 ms
55,608 KB
testcase_04 AC 36 ms
55,608 KB
testcase_05 AC 36 ms
55,608 KB
testcase_06 AC 35 ms
55,608 KB
testcase_07 AC 54 ms
55,608 KB
testcase_08 AC 52 ms
66,536 KB
testcase_09 AC 52 ms
64,416 KB
testcase_10 AC 47 ms
66,524 KB
testcase_11 AC 50 ms
68,624 KB
testcase_12 AC 57 ms
68,612 KB
testcase_13 AC 57 ms
68,616 KB
testcase_14 AC 36 ms
55,608 KB
testcase_15 AC 34 ms
55,608 KB
testcase_16 AC 40 ms
62,088 KB
testcase_17 AC 35 ms
55,608 KB
testcase_18 AC 35 ms
55,608 KB
testcase_19 AC 35 ms
55,608 KB
testcase_20 AC 47 ms
66,536 KB
testcase_21 AC 40 ms
61,528 KB
testcase_22 AC 36 ms
55,608 KB
testcase_23 AC 64 ms
68,620 KB
testcase_24 AC 62 ms
68,620 KB
testcase_25 AC 47 ms
64,452 KB
testcase_26 AC 50 ms
64,184 KB
testcase_27 AC 58 ms
68,612 KB
testcase_28 AC 42 ms
55,608 KB
testcase_29 AC 51 ms
66,528 KB
testcase_30 AC 44 ms
64,456 KB
testcase_31 AC 47 ms
64,300 KB
testcase_32 AC 50 ms
66,520 KB
testcase_33 AC 47 ms
66,520 KB
testcase_34 AC 59 ms
68,628 KB
testcase_35 AC 40 ms
61,576 KB
testcase_36 AC 47 ms
66,520 KB
testcase_37 AC 43 ms
64,300 KB
testcase_38 AC 38 ms
55,608 KB
testcase_39 AC 38 ms
55,608 KB
testcase_40 AC 39 ms
62,088 KB
testcase_41 AC 35 ms
55,608 KB
testcase_42 AC 36 ms
55,608 KB
testcase_43 AC 37 ms
55,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
INF = 10 ** 10
def inp() -> str : return input()
def i() -> int : return int(input())
def lis() -> list[int] : return list(map(int, input().split()))

n = i()
c = i()
v = i()
ss = lis()
tt = lis()
ys = lis()
ms = lis()

graph = [[] for _ in range(n)]
for s, t, y, m in zip(ss, tt, ys, ms):
  graph[s - 1].append([t - 1, y, m])

cost = [[INF] * (c + 1) for _ in range(n)]
cost[0][c] = 0

que = deque([(c, 0)])
while que:
  c, s = que.popleft()
  for t, y, m in graph[s]:
    if y <= c and cost[t][c - y] > cost[s][c] + m:
      cost[t][c - y] = cost[s][c] + m
      que.append((c - y, t))
ans = min(cost[n - 1])
print(-1 if ans == INF else ans)
0