結果

問題 No.37 遊園地のアトラクション
ユーザー ayaoniayaoni
提出日時 2020-12-06 02:24:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 59 ms / 5,000 ms
コード長 890 bytes
コンパイル時間 891 ms
コンパイル使用メモリ 82,356 KB
実行使用メモリ 70,660 KB
最終ジャッジ日時 2024-04-18 20:21:35
合計ジャッジ時間 3,518 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
61,952 KB
testcase_01 AC 45 ms
60,800 KB
testcase_02 AC 49 ms
62,540 KB
testcase_03 AC 49 ms
63,232 KB
testcase_04 AC 47 ms
62,080 KB
testcase_05 AC 48 ms
62,336 KB
testcase_06 AC 47 ms
61,952 KB
testcase_07 AC 56 ms
68,480 KB
testcase_08 AC 45 ms
61,440 KB
testcase_09 AC 44 ms
60,672 KB
testcase_10 AC 54 ms
66,688 KB
testcase_11 AC 54 ms
66,944 KB
testcase_12 AC 48 ms
62,208 KB
testcase_13 AC 50 ms
63,104 KB
testcase_14 AC 47 ms
61,568 KB
testcase_15 AC 48 ms
62,208 KB
testcase_16 AC 51 ms
64,384 KB
testcase_17 AC 50 ms
63,744 KB
testcase_18 AC 59 ms
68,352 KB
testcase_19 AC 44 ms
60,288 KB
testcase_20 AC 49 ms
63,104 KB
testcase_21 AC 46 ms
61,056 KB
testcase_22 AC 58 ms
70,660 KB
testcase_23 AC 38 ms
52,480 KB
testcase_24 AC 36 ms
52,736 KB
testcase_25 AC 36 ms
52,224 KB
testcase_26 AC 37 ms
52,352 KB
testcase_27 AC 49 ms
62,080 KB
testcase_28 AC 43 ms
60,032 KB
testcase_29 AC 47 ms
61,568 KB
testcase_30 AC 38 ms
52,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


T = I()
N = I()
C = LI()
V = LI()

NC = []
NV = []
for i in range(N):
    c = C[i]
    v = V[i]
    while v:
        NC.append(c)
        NV.append(v)
        v //= 2

N = len(NC)

dp = [[0]*(T+1) for _ in range(N+1)]
for i in range(1,N+1):
    c = NC[i-1]
    v = NV[i-1]
    for j in range(T+1):
        if j >= c:
            dp[i][j] = max(dp[i-1][j],dp[i-1][j-c]+v)
        else:
            dp[i][j] = dp[i-1][j]

print(dp[-1][-1])
0