結果

問題 No.2364 Knapsack Problem
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2023-06-30 21:28:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 107 ms / 3,000 ms
コード長 722 bytes
コンパイル時間 330 ms
コンパイル使用メモリ 87,288 KB
実行使用メモリ 76,900 KB
最終ジャッジ日時 2023-09-21 15:15:28
合計ジャッジ時間 3,863 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,456 KB
testcase_01 AC 72 ms
71,428 KB
testcase_02 AC 77 ms
71,400 KB
testcase_03 AC 75 ms
71,428 KB
testcase_04 AC 87 ms
76,604 KB
testcase_05 AC 76 ms
76,844 KB
testcase_06 AC 76 ms
76,448 KB
testcase_07 AC 94 ms
76,712 KB
testcase_08 AC 71 ms
71,320 KB
testcase_09 AC 90 ms
76,684 KB
testcase_10 AC 94 ms
76,608 KB
testcase_11 AC 85 ms
76,836 KB
testcase_12 AC 103 ms
76,620 KB
testcase_13 AC 101 ms
76,612 KB
testcase_14 AC 103 ms
76,696 KB
testcase_15 AC 107 ms
76,708 KB
testcase_16 AC 97 ms
76,900 KB
testcase_17 AC 98 ms
76,668 KB
testcase_18 AC 96 ms
76,868 KB
testcase_19 AC 96 ms
76,576 KB
testcase_20 AC 96 ms
76,692 KB
testcase_21 AC 98 ms
76,668 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

"""

N,M,W = map(int,input().split())

A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
D = list(map(int,input().split()))

for i in range(M):
    A.append(-C[i])
    B.append(-D[i])

dpok = [False] * (2**(N+M))
dpok[0] = True

w = [0] * (2**(N+M))
v = [0] * (2**(N+M))

for i in range(2**(N+M)):

    for j in range(N+M):

        if 2**j & i:
            w[i] += A[j]
            v[i] += B[j]

#print (w,v)
ans = 0
for i in range(2**(N+M)):

    if not dpok[i]:
        continue

    for j in range(N+M):

        if dpok[2**j | i] == False and 0 <= w[2**j | i] <= W:
            dpok[2**j | i] = True
            ans = max(ans , v[2**j | i])

print (ans)


0