結果

問題 No.1 道のショートカット
ユーザー square1001
提出日時 2022-02-17 10:31:14
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 280 ms / 5,000 ms
コード長 531 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-06-29 07:31:30
合計ジャッジ時間 5,085 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
C = int(input())
V = int(input())
S = [ int(x) - 1 for x in input().split() ]
T = [ int(x) - 1 for x in input().split() ]
Y = list(map(int, input().split()))
M = list(map(int, input().split()))

dp = [ [ 10 ** 18 ] * N for i in range(C + 1) ]
dp[0][0] = 0
for i in range(1, C + 1):
	for j in range(V):
		if i >= Y[j]:
			dp[i][T[j]] = min(dp[i][T[j]], dp[i - Y[j]][S[j]] + M[j])

answer = 10 ** 18
for i in range(1, C + 1):
	answer = min(answer, dp[i][N - 1])

if answer < 10 ** 18:
	print(answer)
else:
	print(-1)
0