結果

問題 No.2364 Knapsack Problem
ユーザー ニックネームニックネーム
提出日時 2023-06-30 23:21:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 91 ms / 3,000 ms
コード長 500 bytes
コンパイル時間 456 ms
コンパイル使用メモリ 86,996 KB
実行使用メモリ 76,824 KB
最終ジャッジ日時 2023-09-21 17:38:41
合計ジャッジ時間 3,004 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,212 KB
testcase_01 AC 68 ms
71,280 KB
testcase_02 AC 69 ms
71,416 KB
testcase_03 AC 67 ms
71,468 KB
testcase_04 AC 70 ms
71,368 KB
testcase_05 AC 69 ms
71,224 KB
testcase_06 AC 69 ms
71,288 KB
testcase_07 AC 89 ms
76,704 KB
testcase_08 AC 69 ms
71,356 KB
testcase_09 AC 85 ms
76,560 KB
testcase_10 AC 89 ms
76,712 KB
testcase_11 AC 70 ms
71,204 KB
testcase_12 AC 89 ms
76,452 KB
testcase_13 AC 88 ms
76,564 KB
testcase_14 AC 89 ms
76,508 KB
testcase_15 AC 91 ms
76,716 KB
testcase_16 AC 91 ms
76,456 KB
testcase_17 AC 90 ms
76,640 KB
testcase_18 AC 89 ms
76,500 KB
testcase_19 AC 90 ms
76,676 KB
testcase_20 AC 91 ms
76,824 KB
testcase_21 AC 90 ms
76,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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()))
ac = a+[-w for w in c]
bd = b+[-v for v in d]
v = [-10**9]*(1<<n+m); v[0] = 0
for i in range(1<<n+m):
    if v[i]==-10**9: continue
    s = 0
    for j in range(n+m):
        if i>>j&1: s += ac[j]
    for j in range(n+m):
        if i>>j&1: continue
        if 0<=s+ac[j]<=k: v[i|1<<j] = max(v[i|1<<j],v[i]+bd[j])
print(max(v))
0