結果
| 問題 | No.2364 Knapsack Problem |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-29 09:24:21 |
| 言語 | PyPy3 (7.3.23 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 884 bytes |
| 記録 | |
| コンパイル時間 | 1,487 ms |
| コンパイル使用メモリ | 95,592 KB |
| 実行使用メモリ | 85,376 KB |
| 最終ジャッジ日時 | 2026-08-29 09:24:28 |
| 合計ジャッジ時間 | 4,158 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 WA * 9 |
ソースコード
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()))
ans = 0
for u in range(1<<N):
Box1 = []
for ku in range(N):
if (u>>ku) & 1:
Box1.append((A[ku],B[ku]))
Box1 = sorted(Box1,key=lambda x:-x[0])
for v in range(1<<M):
Box2 = []
for kv in range(M):
if (v>>kv) & 1:
Box2.append((C[kv],D[kv]))
Box2 = sorted(Box2,key=lambda x:x[0])
w = 0
j = 0
vx = 0
for i in range(len(Box1)):
if w+Box1[i][0]<=W:
w += Box1[i][0]
vx += Box1[i][1]
while j<len(Box2) and w>=Box2[j][0]:
w -= Box2[j][0]
vx -= Box2[j][1]
j += 1
ans = max(ans,vx)
print(ans)