結果

問題 No.3014 岩井満足性問題
ユーザー noriaoki
提出日時 2025-01-25 14:45:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,590 ms / 3,000 ms
コード長 425 bytes
コンパイル時間 395 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 77,824 KB
最終ジャッジ日時 2025-01-25 23:29:04
合計ジャッジ時間 8,141 ms
ジャッジサーバーID
(参考情報)
judge1 / judge8
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

n, d, k = map(int, input().split())
a = list(map(int, input().split()))
c = list(map(int, input().split()))
dp = [[-10**18]*(k+1) for _ in range(d+1)]
dp[0][0] = 0
for i in range(n):
    ai, ci = a[i], c[i]
    for j in reversed(range(d)):
        for l in reversed(range(k+1)):
            dp[j+1][min(k, l+ci)] = max(dp[j+1][min(k, l+ci)], dp[j][l] + ai)
if dp[-1][-1] < -10**16:
    print('No')
else:
    print(dp[-1][-1])
0