結果

問題 No.2364 Knapsack Problem
ユーザー miho-4miho-4
提出日時 2023-06-30 22:54:31
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 691 bytes
コンパイル時間 1,907 ms
コンパイル使用メモリ 86,436 KB
実行使用メモリ 78,968 KB
最終ジャッジ日時 2023-09-21 17:08:54
合計ジャッジ時間 9,493 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
75,568 KB
testcase_01 AC 75 ms
71,432 KB
testcase_02 AC 76 ms
71,388 KB
testcase_03 RE -
testcase_04 AC 133 ms
77,668 KB
testcase_05 AC 124 ms
77,612 KB
testcase_06 WA -
testcase_07 RE -
testcase_08 AC 76 ms
71,336 KB
testcase_09 AC 447 ms
78,384 KB
testcase_10 WA -
testcase_11 RE -
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0