結果
問題 |
No.37 遊園地のアトラクション
|
ユーザー |
|
提出日時 | 2023-02-09 00:20:23 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 77 ms / 5,000 ms |
コード長 | 469 bytes |
コンパイル時間 | 147 ms |
コンパイル使用メモリ | 81,912 KB |
実行使用メモリ | 76,016 KB |
最終ジャッジ日時 | 2024-07-06 08:45:34 |
合計ジャッジ時間 | 2,933 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 27 |
ソースコード
t = int(input()) n = int(input()) c = list(map(int, input().split())) v = list(map(int, input().split())) dp = {} dp[0] = 0 for i in range(n): cost = c[i] value = 0 cur = v[i] ndp = {} while cur > 0: value += cur for ck, cv in dp.items(): ndp[ck] = max(ndp.get(ck, -1), cv) if ck + cost <= t: nxt = ck + cost ndp[nxt] = max(ndp.get(nxt, -1), cv + value) cost += c[i] cur //= 2 dp = ndp print(max(dp.values()))