結果
| 問題 |
No.37 遊園地のアトラクション
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-10-10 00:09:12 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 79 ms / 5,000 ms |
| コード長 | 660 bytes |
| コンパイル時間 | 307 ms |
| コンパイル使用メモリ | 82,380 KB |
| 実行使用メモリ | 76,324 KB |
| 最終ジャッジ日時 | 2024-09-12 22:35:44 |
| 合計ジャッジ時間 | 3,422 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()))
CV = [[C[i], V[i]] for i in range(n)]
CV.sort(key=lambda x: (x[0], x[1]))
DP = [0 for _ in range(t + 1)]
for i in range(n):
NDP = [-1 for _ in range(t + 1)]
c, v = CV[i]
for j in range(t + 1):
NDP[j] = max(NDP[j], DP[j])
res = v
curr = v
for k in range(j + c, t + 1, c):
NDP[k] = max(NDP[k], DP[j] + res)
curr //= 2
if curr == 0:
break
res += curr
for j in range(1, t + 1):
NDP[j] = max(NDP[j], NDP[j - 1])
DP = NDP
print(DP[t])