結果
問題 | No.2364 Knapsack Problem |
ユーザー |
|
提出日時 | 2023-06-30 22:09:27 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,251 bytes |
コンパイル時間 | 169 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 84,796 KB |
最終ジャッジ日時 | 2024-07-07 09:57:25 |
合計ジャッジ時間 | 8,340 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 10 TLE * 1 -- * 9 |
ソースコード
import sys, time, randomfrom collections import deque, Counter, defaultdictinput = lambda: sys.stdin.readline().rstrip()ii = lambda: int(input())mi = lambda: map(int, input().split())li = lambda: list(mi())inf = 2 ** 63 - 1mod = 998244353import timet1 = time.time()n, m, w = mi()a = li()b = li()c = [v for v in li()]d = [v for v in li()]ans = 0import itertoolsfor bit1 in range(1 << n):for bit2 in range(1 << m):WV = []for i in range(n):if 1 & (bit1 >> i):WV.append((a[i], b[i]))WIS = []for i in range(m):if 1 & (bit2 >> i):WIS.append((c[i], d[i]))for WV in itertools.permutations(WV):for WIS in itertools.permutations(WIS):j = 0noww = 0nowv = 0for x, y in WV:noww += xnowv += yif noww > w:nowv = -infbreakif j < len(WIS) and WIS[j][0] <= noww:noww -= WIS[j][0]nowv -= WIS[j][1]j += 1ans = max(ans, nowv)print(ans)