結果

問題 No.2364 Knapsack Problem
ユーザー ニックネーム
提出日時 2023-06-30 21:43:52
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 683 bytes
コンパイル時間 126 ms
コンパイル使用メモリ 82,256 KB
実行使用メモリ 76,816 KB
最終ジャッジ日時 2024-07-07 09:23:48
合計ジャッジ時間 5,039 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9 TLE * 2 -- * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import permutations
n,m,k = 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 x in range(n+1):
    for px in permutations(range(n),x):
        for y in range(m+1):
            for py in permutations(range(m),y):
                i = j = w = v = 0
                while i<x or j<y:
                    if i<x and w+a[px[i]]<=k: w += a[px[i]]; v += b[px[i]]; i += 1
                    elif j<y and 0<=w-c[py[j]]: w -= c[py[j]]; v -= d[py[j]]; j += 1
                    else: break
                if i==x and j==y: ans = max(ans,v)
print(ans)
0