結果

問題 No.2364 Knapsack Problem
ユーザー ニックネームニックネーム
提出日時 2023-06-30 21:43:52
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 683 bytes
コンパイル時間 320 ms
コンパイル使用メモリ 87,280 KB
実行使用メモリ 82,312 KB
最終ジャッジ日時 2023-09-21 15:37:47
合計ジャッジ時間 5,632 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
76,012 KB
testcase_01 AC 72 ms
71,540 KB
testcase_02 AC 86 ms
76,160 KB
testcase_03 AC 75 ms
71,408 KB
testcase_04 AC 103 ms
77,572 KB
testcase_05 AC 98 ms
76,208 KB
testcase_06 AC 106 ms
76,920 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

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