結果
| 問題 | No.37 遊園地のアトラクション | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2017-12-13 22:56:28 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 54 ms / 5,000 ms | 
| コード長 | 347 bytes | 
| コンパイル時間 | 361 ms | 
| コンパイル使用メモリ | 82,372 KB | 
| 実行使用メモリ | 62,336 KB | 
| 最終ジャッジ日時 | 2024-10-10 13:28:03 | 
| 合計ジャッジ時間 | 2,863 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 27 | 
ソースコード
T = int(input())
n = int(input())
c = list(map(int, input().split()))
v = list(map(int, input().split()))
f = [0] * (T + 1)
for i in range(n):
  g = [x for x in f]
  total, need = 0, 0
  while v[i]:
    total += v[i]
    need += c[i]
    v[i] >>= 1
    for j in range(need, T + 1):
      g[j] = max(g[j], f[j - need] + total)
  f = g
print(max(f))
            
            
            
        