結果
問題 | No.2364 Knapsack Problem |
ユーザー |
![]() |
提出日時 | 2023-06-30 21:25:19 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 573 bytes |
コンパイル時間 | 158 ms |
コンパイル使用メモリ | 82,152 KB |
実行使用メモリ | 64,456 KB |
最終ジャッジ日時 | 2024-07-07 08:57:20 |
合計ジャッジ時間 | 1,681 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 WA * 2 |
ソースコード
N, M, W = 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())) A = A + C B = B + D ans = -10**18 for s in range(1 << (N + M)): wp, vp, wm, vm = 0, 0, 0, 0 for i in range(N + M): if (s >> i) & 1: if i < N: wp += A[i] vp += B[i] else: wm += A[i] vm += B[i] if wm > wp or wp - wm > W: continue ans = max(ans, vp - vm) print(ans)