結果

問題 No.1 道のショートカット
ユーザー tomiyancetomiyance
提出日時 2019-11-26 20:42:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,265 ms / 5,000 ms
コード長 577 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 10,816 KB
実行使用メモリ 8,784 KB
最終ジャッジ日時 2023-09-27 22:24:15
合計ジャッジ時間 8,521 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,780 KB
testcase_01 AC 15 ms
7,908 KB
testcase_02 AC 15 ms
7,908 KB
testcase_03 AC 14 ms
7,908 KB
testcase_04 AC 15 ms
7,864 KB
testcase_05 AC 15 ms
7,864 KB
testcase_06 AC 14 ms
7,748 KB
testcase_07 AC 15 ms
7,864 KB
testcase_08 AC 350 ms
8,420 KB
testcase_09 AC 71 ms
8,344 KB
testcase_10 AC 208 ms
8,248 KB
testcase_11 AC 356 ms
8,296 KB
testcase_12 AC 1,265 ms
8,648 KB
testcase_13 AC 1,195 ms
8,784 KB
testcase_14 AC 17 ms
8,208 KB
testcase_15 AC 17 ms
8,300 KB
testcase_16 AC 23 ms
8,304 KB
testcase_17 AC 15 ms
8,220 KB
testcase_18 AC 19 ms
7,952 KB
testcase_19 AC 18 ms
8,272 KB
testcase_20 AC 64 ms
8,248 KB
testcase_21 AC 25 ms
8,376 KB
testcase_22 AC 18 ms
8,408 KB
testcase_23 AC 472 ms
8,360 KB
testcase_24 AC 447 ms
8,368 KB
testcase_25 AC 88 ms
8,176 KB
testcase_26 AC 44 ms
8,208 KB
testcase_27 AC 674 ms
8,260 KB
testcase_28 AC 14 ms
7,908 KB
testcase_29 AC 120 ms
8,364 KB
testcase_30 AC 22 ms
7,880 KB
testcase_31 AC 43 ms
8,372 KB
testcase_32 AC 249 ms
8,252 KB
testcase_33 AC 110 ms
8,384 KB
testcase_34 AC 454 ms
8,356 KB
testcase_35 AC 17 ms
8,248 KB
testcase_36 AC 73 ms
8,304 KB
testcase_37 AC 26 ms
8,252 KB
testcase_38 AC 15 ms
7,780 KB
testcase_39 AC 18 ms
8,316 KB
testcase_40 AC 21 ms
8,384 KB
testcase_41 AC 15 ms
7,948 KB
testcase_42 AC 15 ms
7,832 KB
testcase_43 AC 16 ms
8,336 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()))
INF = 1e8
dp = [[INF for i in range(C+1)] for j in range(N+1)]
dp[1][C] = 0
for i in range(1,N+1):
  for j in reversed(range(0,C+1)):
    if dp[i][j] != 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 = INF
for i in range(0,C+1):
  ans = min(ans,dp[N][i])
print(ans if ans < INF else -1)
0