結果

問題 No.37 遊園地のアトラクション
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-06-09 03:33:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 166 ms / 5,000 ms
コード長 651 bytes
コンパイル時間 314 ms
コンパイル使用メモリ 87,228 KB
実行使用メモリ 80,664 KB
最終ジャッジ日時 2023-08-30 03:36:27
合計ジャッジ時間 6,246 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 140 ms
78,456 KB
testcase_01 AC 131 ms
77,840 KB
testcase_02 AC 147 ms
78,644 KB
testcase_03 AC 145 ms
78,412 KB
testcase_04 AC 149 ms
79,876 KB
testcase_05 AC 150 ms
79,656 KB
testcase_06 AC 138 ms
78,580 KB
testcase_07 AC 163 ms
80,432 KB
testcase_08 AC 141 ms
78,528 KB
testcase_09 AC 124 ms
77,732 KB
testcase_10 AC 154 ms
80,664 KB
testcase_11 AC 151 ms
80,576 KB
testcase_12 AC 139 ms
78,596 KB
testcase_13 AC 144 ms
78,504 KB
testcase_14 AC 143 ms
78,612 KB
testcase_15 AC 149 ms
79,688 KB
testcase_16 AC 153 ms
80,028 KB
testcase_17 AC 148 ms
78,588 KB
testcase_18 AC 159 ms
78,576 KB
testcase_19 AC 126 ms
77,896 KB
testcase_20 AC 147 ms
78,536 KB
testcase_21 AC 137 ms
78,400 KB
testcase_22 AC 152 ms
78,576 KB
testcase_23 AC 108 ms
72,852 KB
testcase_24 AC 108 ms
72,904 KB
testcase_25 AC 112 ms
72,908 KB
testcase_26 AC 112 ms
72,844 KB
testcase_27 AC 166 ms
80,108 KB
testcase_28 AC 116 ms
77,816 KB
testcase_29 AC 143 ms
78,584 KB
testcase_30 AC 112 ms
72,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline

T = int(input())
N = int(input())
C = list(map(int,input().split()))
V = list(map(int,input().split()))
dp = [[0]*(T+2) for _ in range(N+1)]
for i in range(N):
    v = V[i]
    c = C[i]
    
    for j in range(T+1):
        dp[i+1][j] = max(dp[i][j],dp[i+1][j])
        tv = v
        sv = tv
        tj = j
        while tv:
            dp[i+1][min(tj+c,T+1)] = max(dp[i+1][min(tj+c,T+1)], dp[i][min(j,T+1)] + sv)
            tv //= 2
            sv += tv
            tj += c

ans = max(dp[-1][:T+1])

print(ans)
0