結果

問題 No.1 道のショートカット
ユーザー taisuketaisuke
提出日時 2023-02-17 15:22:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 114 ms / 5,000 ms
コード長 681 bytes
コンパイル時間 109 ms
コンパイル使用メモリ 10,804 KB
実行使用メモリ 8,860 KB
最終ジャッジ日時 2023-09-26 14:33:03
合計ジャッジ時間 2,999 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,824 KB
testcase_01 AC 17 ms
7,844 KB
testcase_02 AC 16 ms
7,976 KB
testcase_03 AC 17 ms
7,952 KB
testcase_04 AC 16 ms
7,912 KB
testcase_05 AC 16 ms
7,904 KB
testcase_06 AC 16 ms
7,888 KB
testcase_07 AC 16 ms
7,872 KB
testcase_08 AC 29 ms
8,576 KB
testcase_09 AC 21 ms
8,368 KB
testcase_10 AC 24 ms
8,256 KB
testcase_11 AC 48 ms
8,280 KB
testcase_12 AC 74 ms
8,832 KB
testcase_13 AC 65 ms
8,860 KB
testcase_14 AC 17 ms
8,220 KB
testcase_15 AC 17 ms
8,324 KB
testcase_16 AC 19 ms
8,424 KB
testcase_17 AC 17 ms
8,376 KB
testcase_18 AC 17 ms
8,228 KB
testcase_19 AC 18 ms
8,352 KB
testcase_20 AC 22 ms
8,364 KB
testcase_21 AC 19 ms
8,264 KB
testcase_22 AC 18 ms
8,300 KB
testcase_23 AC 114 ms
8,256 KB
testcase_24 AC 112 ms
8,244 KB
testcase_25 AC 31 ms
8,328 KB
testcase_26 AC 24 ms
8,320 KB
testcase_27 AC 84 ms
8,228 KB
testcase_28 AC 16 ms
8,264 KB
testcase_29 AC 30 ms
8,236 KB
testcase_30 AC 18 ms
8,296 KB
testcase_31 AC 27 ms
8,384 KB
testcase_32 AC 34 ms
8,632 KB
testcase_33 AC 24 ms
8,324 KB
testcase_34 AC 81 ms
8,552 KB
testcase_35 AC 18 ms
8,256 KB
testcase_36 AC 21 ms
8,252 KB
testcase_37 AC 18 ms
8,308 KB
testcase_38 AC 16 ms
7,880 KB
testcase_39 AC 18 ms
8,284 KB
testcase_40 AC 17 ms
8,220 KB
testcase_41 AC 17 ms
7,780 KB
testcase_42 AC 16 ms
7,880 KB
testcase_43 AC 18 ms
8,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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()))

graph = [[] for _ in range(n)]
for i in range(v):
    graph[s[i] - 1].append([t[i] - 1, y[i], m[i]])

INF = 10**9
dp = [[INF for i in range(c+1)] for j in range(n)]
dp[0][0] = 0

for i in range(n):
    for j in range(c+1):
        if dp[i][j] == INF:
            continue
        for u in graph[i]:
            if u[1] + j > c:
                continue
            dp[u[0]][u[1] + j] = min(dp[u[0]][u[1] + j], dp[i][j] + u[2])
ans = min(dp[n-1])
if ans == INF:
    ans = -1
print(ans)
0