結果

問題 No.1 道のショートカット
ユーザー tomiyance
提出日時 2019-11-26 20:34:20
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 575 bytes
コンパイル時間 103 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-07-08 05:18:55
合計ジャッジ時間 8,677 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 36 WA * 4
権限があれば一括ダウンロードができます

ソースコード

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(i,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(C+1):
  ans = min(ans,dp[N][i])
print(ans if ans < INF else -1)
0