結果
| 問題 |
No.2364 Knapsack Problem
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-06-30 22:54:31 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 691 bytes |
| コンパイル時間 | 283 ms |
| コンパイル使用メモリ | 82,424 KB |
| 実行使用メモリ | 83,616 KB |
| 最終ジャッジ日時 | 2024-07-07 10:47:08 |
| 合計ジャッジ時間 | 7,184 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 5 WA * 2 RE * 3 TLE * 1 -- * 9 |
ソースコード
import itertools
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()))
ITER=[i for i in range(n+1)]
ans=0
for bit in itertools.product([1,0], repeat=n):
for M in itertools.product(ITER, repeat=m):
tmpA=A[:]
tmpB=B[:]
flag=1
for j in range(m):
if M[j]==n:continue
tmpA[M[j]]-=C[M[j]]
tmpB[M[j]]-=D[M[j]]
if tmpA[M[j]]<0:flag=0
if tmpB[M[j]]<0:flag=0
if flag:
tmp=[0,0]
for i in range(n):
if bit[i]:
tmp[0]+=tmpA[i]
tmp[1]+=tmpB[i]
if tmp[0]<=w:
ans=max(ans,tmp[1])
print(ans)