結果

問題 No.1 道のショートカット
ユーザー netyo715netyo715
提出日時 2021-07-09 11:06:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 173 ms / 5,000 ms
コード長 631 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 10,776 KB
実行使用メモリ 8,920 KB
最終ジャッジ日時 2023-09-14 06:24:09
合計ジャッジ時間 3,944 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,836 KB
testcase_01 AC 16 ms
7,792 KB
testcase_02 AC 16 ms
7,748 KB
testcase_03 AC 16 ms
7,776 KB
testcase_04 AC 16 ms
7,776 KB
testcase_05 AC 17 ms
7,788 KB
testcase_06 AC 16 ms
7,836 KB
testcase_07 AC 16 ms
7,712 KB
testcase_08 AC 129 ms
8,500 KB
testcase_09 AC 74 ms
8,232 KB
testcase_10 AC 51 ms
8,384 KB
testcase_11 AC 75 ms
8,272 KB
testcase_12 AC 173 ms
8,920 KB
testcase_13 AC 163 ms
8,844 KB
testcase_14 AC 24 ms
8,192 KB
testcase_15 AC 17 ms
8,188 KB
testcase_16 AC 36 ms
8,420 KB
testcase_17 AC 17 ms
8,220 KB
testcase_18 AC 24 ms
8,236 KB
testcase_19 AC 34 ms
8,316 KB
testcase_20 AC 38 ms
8,320 KB
testcase_21 AC 45 ms
8,328 KB
testcase_22 AC 29 ms
8,288 KB
testcase_23 AC 137 ms
8,236 KB
testcase_24 AC 156 ms
8,212 KB
testcase_25 AC 62 ms
8,416 KB
testcase_26 AC 48 ms
8,208 KB
testcase_27 AC 116 ms
8,216 KB
testcase_28 AC 18 ms
8,180 KB
testcase_29 AC 35 ms
8,332 KB
testcase_30 AC 20 ms
8,184 KB
testcase_31 AC 31 ms
8,232 KB
testcase_32 AC 96 ms
8,572 KB
testcase_33 AC 68 ms
8,264 KB
testcase_34 AC 115 ms
8,584 KB
testcase_35 AC 20 ms
8,344 KB
testcase_36 AC 34 ms
8,212 KB
testcase_37 AC 20 ms
8,320 KB
testcase_38 AC 19 ms
7,808 KB
testcase_39 AC 33 ms
8,296 KB
testcase_40 AC 20 ms
8,356 KB
testcase_41 AC 18 ms
7,716 KB
testcase_42 AC 16 ms
7,804 KB
testcase_43 AC 17 ms
8,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
C = int(input())
V = int(input())
S = list(map(lambda x: int(x)-1, input().split()))
T = list(map(lambda x: int(x)-1, input().split()))
Y = list(map(int, input().split()))
M = list(map(int, input().split()))
INF = 10**10
edge = [[] for _ in range(N)]
for s, t, y, m in zip(S, T, Y, M):
    edge[s].append([t, y, m])
dp = [[INF]*(C+10) for _ in range(N+10)]
dp[0][0] = 0

for i in range(N-1):
    for t, y, m in edge[i]:
        for j in range(C+1):
            if j+y > C:
                break
            dp[t][j+y] = min(dp[t][j+y], dp[i][j]+m)

if min(dp[N-1])==INF:
    print(-1)
else:
    print(min(dp[N-1]))
0