結果

問題 No.37 遊園地のアトラクション
ユーザー maspymaspy
提出日時 2020-03-12 23:33:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 532 ms / 5,000 ms
コード長 639 bytes
コンパイル時間 239 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 44,600 KB
最終ジャッジ日時 2024-04-18 20:15:47
合計ジャッジ時間 17,432 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 515 ms
44,424 KB
testcase_01 AC 511 ms
44,076 KB
testcase_02 AC 532 ms
44,080 KB
testcase_03 AC 500 ms
44,208 KB
testcase_04 AC 508 ms
44,336 KB
testcase_05 AC 513 ms
44,212 KB
testcase_06 AC 515 ms
44,464 KB
testcase_07 AC 504 ms
44,112 KB
testcase_08 AC 506 ms
44,076 KB
testcase_09 AC 507 ms
44,080 KB
testcase_10 AC 528 ms
44,340 KB
testcase_11 AC 502 ms
44,348 KB
testcase_12 AC 507 ms
44,212 KB
testcase_13 AC 512 ms
44,208 KB
testcase_14 AC 506 ms
44,340 KB
testcase_15 AC 506 ms
44,212 KB
testcase_16 AC 522 ms
44,084 KB
testcase_17 AC 523 ms
44,464 KB
testcase_18 AC 499 ms
43,956 KB
testcase_19 AC 509 ms
44,188 KB
testcase_20 AC 503 ms
44,336 KB
testcase_21 AC 525 ms
44,212 KB
testcase_22 AC 508 ms
44,076 KB
testcase_23 AC 506 ms
44,212 KB
testcase_24 AC 521 ms
43,956 KB
testcase_25 AC 512 ms
44,460 KB
testcase_26 AC 504 ms
44,072 KB
testcase_27 AC 505 ms
43,964 KB
testcase_28 AC 505 ms
44,088 KB
testcase_29 AC 506 ms
44,600 KB
testcase_30 AC 511 ms
44,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3.8
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

# %%
T = int(readline())
N = int(readline())
C = tuple(map(int, readline().split()))
V = tuple(map(int, readline().split()))


# %%
dp = np.zeros(T + 1, np.int64)
for c, v in zip(C, V):
    newdp = dp.copy()
    total_c = 0
    total_v = 0
    while v:
        total_c += c
        total_v += v
        v //= 2
        if total_c > T:
            break
        np.maximum(newdp[total_c:], dp[:-total_c] + total_v, out=newdp[total_c:])
    dp = newdp


# %%
print(dp.max())
0