結果

問題 No.2364 Knapsack Problem
ユーザー nasutarou1341nasutarou1341
提出日時 2023-06-30 21:34:37
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 657 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 87,144 KB
実行使用メモリ 77,516 KB
最終ジャッジ日時 2023-09-21 15:25:06
合計ジャッジ時間 17,301 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,288 KB
testcase_01 WA -
testcase_02 AC 86 ms
76,148 KB
testcase_03 AC 77 ms
71,476 KB
testcase_04 AC 85 ms
76,148 KB
testcase_05 AC 99 ms
76,088 KB
testcase_06 WA -
testcase_07 AC 669 ms
77,276 KB
testcase_08 AC 75 ms
71,488 KB
testcase_09 AC 116 ms
76,956 KB
testcase_10 AC 180 ms
77,516 KB
testcase_11 AC 99 ms
76,748 KB
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M, W = list(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
import itertools
for n in itertools.permutations(range(N), N):
  for m in itertools.permutations(range(M), M):
    w = 0
    v = 0
    ni = 0
    mi = 0
    while True:
      while ni < N:
        if w + A[n[ni]] > W:
          break
        w += A[n[ni]]
        v += B[n[ni]]
        ni += 1
      ans = max(ans, v)
      if mi == M: break
      if w - C[m[mi]] < 0: break
      w -= C[m[mi]]
      v -= D[m[mi]]
      ni += 1
      if ni == N: break
print(ans)
0