結果

問題 No.1 道のショートカット
ユーザー koukou
提出日時 2019-12-16 21:55:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 83 ms / 5,000 ms
コード長 410 bytes
コンパイル時間 834 ms
コンパイル使用メモリ 10,740 KB
実行使用メモリ 8,776 KB
最終ジャッジ日時 2023-09-27 22:25:01
合計ジャッジ時間 2,801 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
7,752 KB
testcase_01 AC 14 ms
7,904 KB
testcase_02 AC 16 ms
7,848 KB
testcase_03 AC 16 ms
7,884 KB
testcase_04 AC 16 ms
7,812 KB
testcase_05 AC 14 ms
7,880 KB
testcase_06 AC 14 ms
7,948 KB
testcase_07 AC 14 ms
7,784 KB
testcase_08 AC 60 ms
8,592 KB
testcase_09 AC 38 ms
8,612 KB
testcase_10 AC 30 ms
8,640 KB
testcase_11 AC 41 ms
8,560 KB
testcase_12 AC 77 ms
8,720 KB
testcase_13 AC 83 ms
8,716 KB
testcase_14 AC 18 ms
7,828 KB
testcase_15 AC 15 ms
8,188 KB
testcase_16 AC 23 ms
8,268 KB
testcase_17 AC 15 ms
7,744 KB
testcase_18 AC 18 ms
7,748 KB
testcase_19 AC 22 ms
8,224 KB
testcase_20 AC 24 ms
8,308 KB
testcase_21 AC 25 ms
8,308 KB
testcase_22 AC 20 ms
8,148 KB
testcase_23 AC 65 ms
8,632 KB
testcase_24 AC 72 ms
8,416 KB
testcase_25 AC 35 ms
8,204 KB
testcase_26 AC 27 ms
7,828 KB
testcase_27 AC 60 ms
8,092 KB
testcase_28 AC 15 ms
7,824 KB
testcase_29 AC 24 ms
8,584 KB
testcase_30 AC 17 ms
7,776 KB
testcase_31 AC 22 ms
8,408 KB
testcase_32 AC 53 ms
8,488 KB
testcase_33 AC 39 ms
8,340 KB
testcase_34 AC 59 ms
8,776 KB
testcase_35 AC 17 ms
8,072 KB
testcase_36 AC 23 ms
8,436 KB
testcase_37 AC 17 ms
8,496 KB
testcase_38 AC 16 ms
7,740 KB
testcase_39 AC 21 ms
8,428 KB
testcase_40 AC 17 ms
8,268 KB
testcase_41 AC 15 ms
7,784 KB
testcase_42 AC 15 ms
7,820 KB
testcase_43 AC 14 ms
8,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, c, v, *L = map(int, open(0).read().split())
g = [[] for _ in range(n)]
for s, t, y, m in zip(L, L[v:], L[2 * v:], L[3 * v:]):
	g[s - 1].append((t - 1, y, m))

dp = [[1 << 30] * (c + 1) for _ in range(n)]
dp[0][c] = 0
for f in range(n):
	for t, y, m in g[f]:
		for i in range(y, c + 1):
			if dp[f][i] + m < dp[t][i - y]:
				dp[t][i - y] = dp[f][i] + m
ans = min(dp[-1])
print(ans if ans != 1 << 30 else -1)
0