結果

問題 No.37 遊園地のアトラクション
ユーザー H3PO4H3PO4
提出日時 2023-03-15 13:00:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 887 ms / 5,000 ms
コード長 444 bytes
コンパイル時間 377 ms
コンパイル使用メモリ 11,920 KB
実行使用メモリ 10,832 KB
最終ジャッジ日時 2023-10-18 12:21:23
合計ジャッジ時間 8,059 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
10,440 KB
testcase_01 AC 29 ms
10,088 KB
testcase_02 AC 146 ms
10,292 KB
testcase_03 AC 216 ms
10,652 KB
testcase_04 AC 86 ms
10,168 KB
testcase_05 AC 141 ms
10,216 KB
testcase_06 AC 129 ms
10,592 KB
testcase_07 AC 639 ms
10,800 KB
testcase_08 AC 85 ms
10,356 KB
testcase_09 AC 43 ms
10,208 KB
testcase_10 AC 491 ms
10,592 KB
testcase_11 AC 487 ms
10,800 KB
testcase_12 AC 143 ms
10,372 KB
testcase_13 AC 192 ms
10,552 KB
testcase_14 AC 95 ms
10,452 KB
testcase_15 AC 104 ms
10,196 KB
testcase_16 AC 291 ms
10,612 KB
testcase_17 AC 237 ms
10,752 KB
testcase_18 AC 614 ms
10,688 KB
testcase_19 AC 43 ms
10,208 KB
testcase_20 AC 215 ms
10,392 KB
testcase_21 AC 108 ms
10,680 KB
testcase_22 AC 887 ms
10,832 KB
testcase_23 AC 28 ms
10,088 KB
testcase_24 AC 28 ms
10,088 KB
testcase_25 AC 28 ms
10,088 KB
testcase_26 AC 29 ms
10,088 KB
testcase_27 AC 119 ms
10,232 KB
testcase_28 AC 29 ms
10,088 KB
testcase_29 AC 78 ms
10,176 KB
testcase_30 AC 30 ms
10,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
N = int(input())
C = tuple(map(int, input().split()))
V = tuple(map(int, input().split()))

dp = [0] * (T + 1)
for c, v in zip(C, V):
    new_dp = dp.copy()
    u = 0
    for n in range(v.bit_length()):
        u += v >> n
        if T < c * (n + 1) - 1:
            break
        for i in range(T - c * (n + 1) + 1):
            new_dp[i + c * (n + 1)] = max(new_dp[i + c * (n + 1)], dp[i] + u)
    dp = new_dp
print(max(dp))
0