結果

問題 No.1 道のショートカット
ユーザー szkhtsszkhts
提出日時 2021-12-29 11:28:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,461 ms / 5,000 ms
コード長 643 bytes
コンパイル時間 379 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-04-14 17:04:51
合計ジャッジ時間 10,464 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,752 KB
testcase_01 AC 30 ms
10,752 KB
testcase_02 AC 31 ms
10,752 KB
testcase_03 AC 29 ms
10,880 KB
testcase_04 AC 30 ms
10,752 KB
testcase_05 AC 29 ms
10,752 KB
testcase_06 AC 30 ms
10,752 KB
testcase_07 AC 30 ms
10,752 KB
testcase_08 AC 426 ms
11,008 KB
testcase_09 AC 91 ms
10,880 KB
testcase_10 AC 247 ms
11,008 KB
testcase_11 AC 432 ms
10,880 KB
testcase_12 AC 1,461 ms
11,264 KB
testcase_13 AC 1,331 ms
11,136 KB
testcase_14 AC 31 ms
10,752 KB
testcase_15 AC 31 ms
10,752 KB
testcase_16 AC 39 ms
11,008 KB
testcase_17 AC 30 ms
10,752 KB
testcase_18 AC 33 ms
10,880 KB
testcase_19 AC 33 ms
10,880 KB
testcase_20 AC 81 ms
10,880 KB
testcase_21 AC 42 ms
10,880 KB
testcase_22 AC 33 ms
10,752 KB
testcase_23 AC 576 ms
10,880 KB
testcase_24 AC 558 ms
10,880 KB
testcase_25 AC 108 ms
10,880 KB
testcase_26 AC 62 ms
10,752 KB
testcase_27 AC 788 ms
11,008 KB
testcase_28 AC 30 ms
10,752 KB
testcase_29 AC 159 ms
10,880 KB
testcase_30 AC 39 ms
10,752 KB
testcase_31 AC 64 ms
11,008 KB
testcase_32 AC 309 ms
11,008 KB
testcase_33 AC 139 ms
10,880 KB
testcase_34 AC 563 ms
11,008 KB
testcase_35 AC 32 ms
10,880 KB
testcase_36 AC 101 ms
10,880 KB
testcase_37 AC 44 ms
10,880 KB
testcase_38 AC 30 ms
10,752 KB
testcase_39 AC 33 ms
10,880 KB
testcase_40 AC 37 ms
10,752 KB
testcase_41 AC 30 ms
10,752 KB
testcase_42 AC 30 ms
10,752 KB
testcase_43 AC 32 ms
11,008 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()))

f_inf = float('inf')
dp = [[f_inf] * (c + 1) for _ in range(n + 1)]

dp[1][c] = 0
for i in range(1, n + 1):
    for j in range(c, -1, -1):
        if dp[i][j] != f_inf:
            for k in range(v):
                if i == s[k] and j - y[k] >= 0:
                    dp[t[k]][j - y[k]] = min(dp[i][j] + m[k], dp[t[k]][j - y[k]])

ans = f_inf
for i in range(c + 1):
    ans = min(ans, dp[n][i])

if ans >= f_inf:
    print(-1)
else:
    print(ans)
0