結果

問題 No.37 遊園地のアトラクション
ユーザー rlangevinrlangevin
提出日時 2023-08-07 12:21:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 88 ms / 5,000 ms
コード長 518 bytes
コンパイル時間 176 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 73,984 KB
最終ジャッジ日時 2024-04-25 06:10:52
合計ジャッジ時間 3,425 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
65,664 KB
testcase_01 AC 54 ms
60,800 KB
testcase_02 AC 70 ms
65,792 KB
testcase_03 AC 68 ms
66,432 KB
testcase_04 AC 60 ms
62,592 KB
testcase_05 AC 68 ms
65,536 KB
testcase_06 AC 67 ms
65,536 KB
testcase_07 AC 88 ms
73,984 KB
testcase_08 AC 62 ms
63,744 KB
testcase_09 AC 58 ms
61,952 KB
testcase_10 AC 83 ms
71,040 KB
testcase_11 AC 80 ms
71,168 KB
testcase_12 AC 65 ms
65,280 KB
testcase_13 AC 66 ms
65,408 KB
testcase_14 AC 62 ms
64,256 KB
testcase_15 AC 64 ms
65,152 KB
testcase_16 AC 73 ms
68,096 KB
testcase_17 AC 70 ms
66,432 KB
testcase_18 AC 85 ms
72,320 KB
testcase_19 AC 57 ms
62,208 KB
testcase_20 AC 69 ms
66,944 KB
testcase_21 AC 60 ms
63,232 KB
testcase_22 AC 81 ms
73,600 KB
testcase_23 AC 42 ms
51,840 KB
testcase_24 AC 42 ms
51,840 KB
testcase_25 AC 42 ms
51,840 KB
testcase_26 AC 48 ms
58,240 KB
testcase_27 AC 67 ms
65,536 KB
testcase_28 AC 51 ms
60,928 KB
testcase_29 AC 65 ms
64,128 KB
testcase_30 AC 43 ms
52,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
N = int(input())
c = list(map(int, input().split()))
v = list(map(int, input().split()))
C, V = [], []
now = 1
for _ in range(10):
    for i in range(N):
        C.append(c[i])
        V.append(v[i]//now)
    now *= 2

N *= 10
inf = 10 ** 18
pre = [-inf] * (T + 1)
pre[0] = 0
for i in range(N):
    dp = [-inf] * (T + 1)
    for t in range(T + 1):
        dp[t] = max(dp[t], pre[t])
        if t - C[i] >= 0:
             dp[t] = max(dp[t], pre[t - C[i]] + V[i])
    dp, pre = pre, dp

print(max(pre))
0