結果
問題 |
No.3014 岩井満足性問題
|
ユーザー |
|
提出日時 | 2025-03-21 23:33:40 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,199 ms / 3,000 ms |
コード長 | 552 bytes |
コンパイル時間 | 1,328 ms |
コンパイル使用メモリ | 82,552 KB |
実行使用メモリ | 80,012 KB |
最終ジャッジ日時 | 2025-03-21 23:33:50 |
合計ジャッジ時間 | 7,788 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
import sys INF = float('-inf') n, d, k = map(int, sys.stdin.readline().split()) a = list(map(int, sys.stdin.readline().split())) c = list(map(int, sys.stdin.readline().split())) dp = [[INF] * (k + 1) for _ in range(d + 1)] dp[0][0] = 0 for i in range(n): for j in range(d - 1, -1, -1): for l in range(k, -1, -1): if dp[j][l] != INF: new_k = min(k, l + c[i]) dp[j + 1][new_k] = max(dp[j + 1][new_k], dp[j][l] + a[i]) ans = dp[d][k] if ans == INF: print("No") else: print(ans)