結果
問題 | No.2364 Knapsack Problem |
ユーザー | Shirotsume |
提出日時 | 2023-06-30 21:51:14 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,167 bytes |
コンパイル時間 | 321 ms |
コンパイル使用メモリ | 87,192 KB |
実行使用メモリ | 82,212 KB |
最終ジャッジ日時 | 2023-09-21 15:47:04 |
合計ジャッジ時間 | 18,064 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 112 ms
74,404 KB |
testcase_01 | AC | 112 ms
74,836 KB |
testcase_02 | AC | 127 ms
79,008 KB |
testcase_03 | AC | 113 ms
74,976 KB |
testcase_04 | AC | 128 ms
79,168 KB |
testcase_05 | AC | 168 ms
81,552 KB |
testcase_06 | AC | 128 ms
78,976 KB |
testcase_07 | AC | 317 ms
81,544 KB |
testcase_08 | AC | 115 ms
74,808 KB |
testcase_09 | WA | - |
testcase_10 | AC | 236 ms
81,660 KB |
testcase_11 | AC | 136 ms
80,400 KB |
testcase_12 | AC | 1,495 ms
81,944 KB |
testcase_13 | AC | 1,359 ms
81,588 KB |
testcase_14 | WA | - |
testcase_15 | AC | 1,463 ms
81,880 KB |
testcase_16 | AC | 1,523 ms
81,932 KB |
testcase_17 | AC | 1,528 ms
81,744 KB |
testcase_18 | AC | 1,351 ms
82,144 KB |
testcase_19 | AC | 1,483 ms
81,840 KB |
testcase_20 | AC | 1,498 ms
82,212 KB |
testcase_21 | AC | 1,504 ms
81,980 KB |
ソースコード
import sys, time, random from collections import deque, Counter, defaultdict input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 63 - 1 mod = 998244353 import time t1 = time.time() n, m, w = mi() a = li() b = li() c = [-v for v in li()] d = [-v for v in li()] ans = 0 import itertools for bit1 in range(1 << n): for bit2 in range(1 << m): WV = [(0, 0)] for i in range(n): if 1 & (bit1 >> i): WV.append((a[i], b[i])) WIS = [(0, 0)] for i in range(m): if 1 & (bit2 >> i): WIS.append((c[i], d[i])) for WIS in itertools.permutations(WIS): j = 0 noww = 0 nowv = 0 for x, y in WV: noww += x nowv += y if noww > w: nowv = -inf break if j < len(WIS) and WIS[j][0] <= noww: noww += WIS[j][0] nowv += WIS[j][1] j += 1 ans = max(ans, nowv) print(ans)