結果

問題 No.2364 Knapsack Problem
ユーザー flippergoflippergo
提出日時 2024-10-25 13:39:01
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 531 bytes
コンパイル時間 510 ms
コンパイル使用メモリ 82,532 KB
実行使用メモリ 63,144 KB
最終ジャッジ日時 2024-10-25 13:39:04
合計ジャッジ時間 3,032 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18 WA * 2
権限があれば一括ダウンロードができます

ソースコード

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()))
ans = 0
for i in range(1<<N):
    w = 0
    v = 0
    for k in range(N):
        if (i>>k)&1:
            w += A[k]
            v += B[k]
    for j in range(1<<M):
        w0 = w
        v0 = v
        for l in range(M):
            if (j>>l)&1:
                w0 -= C[l]
                v0 -= D[l]
        if w0<=W:
            ans = max(ans,v0)
print(ans)
0