結果

問題 No.37 遊園地のアトラクション
ユーザー ytftytft
提出日時 2022-11-04 21:35:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 94 ms / 5,000 ms
コード長 621 bytes
コンパイル時間 1,758 ms
コンパイル使用メモリ 86,372 KB
実行使用メモリ 75,836 KB
最終ジャッジ日時 2023-09-25 23:51:11
合計ジャッジ時間 5,137 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
75,800 KB
testcase_01 AC 74 ms
75,348 KB
testcase_02 AC 80 ms
75,464 KB
testcase_03 AC 80 ms
75,468 KB
testcase_04 AC 79 ms
75,352 KB
testcase_05 AC 82 ms
75,408 KB
testcase_06 AC 79 ms
75,324 KB
testcase_07 AC 91 ms
75,388 KB
testcase_08 AC 78 ms
75,388 KB
testcase_09 AC 76 ms
75,304 KB
testcase_10 AC 89 ms
75,744 KB
testcase_11 AC 89 ms
75,680 KB
testcase_12 AC 81 ms
75,572 KB
testcase_13 AC 81 ms
75,448 KB
testcase_14 AC 78 ms
75,356 KB
testcase_15 AC 80 ms
75,532 KB
testcase_16 AC 82 ms
75,520 KB
testcase_17 AC 80 ms
75,376 KB
testcase_18 AC 90 ms
75,452 KB
testcase_19 AC 77 ms
75,496 KB
testcase_20 AC 82 ms
75,372 KB
testcase_21 AC 76 ms
75,524 KB
testcase_22 AC 94 ms
75,836 KB
testcase_23 AC 67 ms
71,128 KB
testcase_24 AC 67 ms
71,028 KB
testcase_25 AC 68 ms
70,952 KB
testcase_26 AC 67 ms
70,980 KB
testcase_27 AC 78 ms
75,344 KB
testcase_28 AC 73 ms
75,152 KB
testcase_29 AC 77 ms
75,472 KB
testcase_30 AC 68 ms
70,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda:sys.stdin.readline().rstrip()
def knapsack(items,capacity):
    N=len(items)
    dp=[[0 for i in range(capacity+1)] for j in range(N+1)]
    for i in range(N):
        for j in range(min(capacity+1,items[i][0])):
            dp[i+1][j]=dp[i][j]
        for j in range(items[i][0],capacity+1):
            dp[i+1][j]=max(dp[i][j],dp[i][j-items[i][0]]+items[i][1])
    return dp[N][capacity]
T,N=[int(input()) for i in range(2)]
C=list(map(int,input().split()))
V=list(map(int,input().split()))
items=[]
for i in range(N):
	while V[i]:
		items.append([C[i],V[i]])
		V[i]//=2
print(knapsack(items,T))
0