結果

問題 No.2730 Two Types Luggage
ユーザー YhuanDebesteYhuanDebeste
提出日時 2024-04-19 22:33:56
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 697 bytes
コンパイル時間 203 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 852,148 KB
最終ジャッジ日時 2024-04-19 22:34:31
合計ジャッジ時間 10,008 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
52,096 KB
testcase_01 AC 44 ms
51,584 KB
testcase_02 AC 45 ms
52,224 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 TLE -
testcase_12 MLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m, w = [int(x) for x in input().split()]
a = list(map(int, input().split()))
b = [1 for _ in range(len(a))]
c = list(map(int, input().split()))
d = list(map(int, input().split()))
def knapsack(wt, val, W, n):
    if n == 0 or W == 0:
        return 0
    if t[n][W] != -1:
        return t[n][W]
    if wt[n-1] <= W:
        t[n][W] = max(
            val[n-1] + knapsack(
                wt, val, W-wt[n-1], n-1),
            knapsack(wt, val, W, n-1))
        return t[n][W]
    elif wt[n-1] > W:
        t[n][W] = knapsack(wt, val, W, n-1)
        return t[n][W]
value = a + d
weight = b + c
n += m
t = [[-1 for i in range(w + 1)] for j in range(n + 1)]
print(knapsack(weight, value, w, n))
0