結果

問題 No.1 道のショートカット
ユーザー nagitaosunagitaosu
提出日時 2020-03-13 00:57:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 116 ms / 5,000 ms
コード長 696 bytes
コンパイル時間 706 ms
コンパイル使用メモリ 10,920 KB
実行使用メモリ 8,852 KB
最終ジャッジ日時 2023-09-27 22:26:08
合計ジャッジ時間 3,274 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,816 KB
testcase_01 AC 16 ms
7,772 KB
testcase_02 AC 16 ms
7,780 KB
testcase_03 AC 16 ms
7,912 KB
testcase_04 AC 16 ms
7,944 KB
testcase_05 AC 16 ms
7,740 KB
testcase_06 AC 16 ms
7,800 KB
testcase_07 AC 16 ms
7,828 KB
testcase_08 AC 44 ms
8,456 KB
testcase_09 AC 29 ms
8,224 KB
testcase_10 AC 28 ms
8,312 KB
testcase_11 AC 50 ms
8,304 KB
testcase_12 AC 80 ms
8,852 KB
testcase_13 AC 72 ms
8,760 KB
testcase_14 AC 18 ms
8,336 KB
testcase_15 AC 17 ms
8,292 KB
testcase_16 AC 21 ms
8,304 KB
testcase_17 AC 17 ms
8,280 KB
testcase_18 AC 18 ms
8,156 KB
testcase_19 AC 20 ms
8,248 KB
testcase_20 AC 25 ms
8,404 KB
testcase_21 AC 22 ms
8,248 KB
testcase_22 AC 19 ms
8,392 KB
testcase_23 AC 113 ms
8,304 KB
testcase_24 AC 116 ms
8,300 KB
testcase_25 AC 37 ms
8,296 KB
testcase_26 AC 27 ms
8,232 KB
testcase_27 AC 85 ms
8,160 KB
testcase_28 AC 17 ms
7,784 KB
testcase_29 AC 30 ms
8,248 KB
testcase_30 AC 19 ms
8,336 KB
testcase_31 AC 29 ms
8,232 KB
testcase_32 AC 43 ms
8,356 KB
testcase_33 AC 31 ms
8,160 KB
testcase_34 AC 77 ms
8,572 KB
testcase_35 AC 19 ms
8,212 KB
testcase_36 AC 23 ms
8,236 KB
testcase_37 AC 20 ms
8,232 KB
testcase_38 AC 17 ms
7,784 KB
testcase_39 AC 21 ms
8,292 KB
testcase_40 AC 18 ms
8,180 KB
testcase_41 AC 17 ms
7,976 KB
testcase_42 AC 16 ms
7,824 KB
testcase_43 AC 16 ms
8,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
import sys
input = sys.stdin.readline
INF = 10**9

n = int(input())
c = int(input())
v = int(input())
ss = [int(item) for item in input().split()]
ts = [int(item) for item in input().split()]
ys = [int(item) for item in input().split()]
ms = [int(item) for item in input().split()]
edge = []
for s, t, y, m in zip(ss, ts, ys, ms):
    s -= 1; t -= 1
    edge.append((s, t, y, m))
edge.sort()

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

for s, t, y, m in edge:
    for i in range(y, c + 1):
        if dp[s][i] == INF:
            continue
        dp[t][i - y] = min(dp[t][i - y], dp[s][i] + m)
ans = min(dp[-1])
if ans == INF:
    print(-1)
else:
    print(ans)
0