結果

問題 No.1 道のショートカット
ユーザー tomiyance
提出日時 2019-11-26 20:42:20
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 1,454 ms / 5,000 ms
コード長 577 bytes
コンパイル時間 340 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-07-20 16:43:57
合計ジャッジ時間 9,391 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

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