結果
| 問題 |
No.2364 Knapsack Problem
|
| コンテスト | |
| ユーザー |
ニックネーム
|
| 提出日時 | 2023-06-30 23:20:11 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 557 bytes |
| コンパイル時間 | 176 ms |
| コンパイル使用メモリ | 82,196 KB |
| 実行使用メモリ | 69,756 KB |
| 最終ジャッジ日時 | 2024-07-07 11:14:47 |
| 合計ジャッジ時間 | 1,805 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 WA * 2 |
ソースコード
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]
f = [False]*(1<<n+m); f[0] = True; v = [0]*(1<<n+m)
for i in range(1<<n+m):
if not f[i]: 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:
f[i|1<<j] = True
v[i|1<<j] = max(v[i|1<<j],v[i]+bd[j])
print(max(v))
ニックネーム