結果

問題 No.2364 Knapsack Problem
ユーザー rlangevinrlangevin
提出日時 2023-06-30 21:25:19
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 573 bytes
コンパイル時間 382 ms
コンパイル使用メモリ 86,996 KB
実行使用メモリ 76,668 KB
最終ジャッジ日時 2023-09-21 15:11:54
合計ジャッジ時間 3,113 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,396 KB
testcase_01 AC 69 ms
71,148 KB
testcase_02 AC 70 ms
71,136 KB
testcase_03 AC 74 ms
71,236 KB
testcase_04 AC 75 ms
76,388 KB
testcase_05 AC 77 ms
76,364 KB
testcase_06 AC 75 ms
76,208 KB
testcase_07 AC 84 ms
76,396 KB
testcase_08 AC 68 ms
71,208 KB
testcase_09 WA -
testcase_10 AC 79 ms
76,456 KB
testcase_11 AC 79 ms
76,360 KB
testcase_12 AC 83 ms
76,308 KB
testcase_13 AC 86 ms
76,576 KB
testcase_14 WA -
testcase_15 AC 84 ms
76,388 KB
testcase_16 AC 85 ms
76,356 KB
testcase_17 AC 84 ms
76,188 KB
testcase_18 AC 84 ms
76,444 KB
testcase_19 AC 84 ms
76,456 KB
testcase_20 AC 84 ms
76,668 KB
testcase_21 AC 84 ms
76,484 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()))
A = A + C
B = B + D
ans = -10**18
for s in range(1 << (N + M)):
    wp, vp, wm, vm = 0, 0, 0, 0
    for i in range(N + M):
        if (s >> i) & 1:
            if i < N:
                wp += A[i]
                vp += B[i]
            else:
                wm += A[i]
                vm += B[i]
    if wm > wp or wp - wm > W:
        continue
    ans = max(ans, vp - vm)
    
print(ans)
    
0