結果

問題 No.2364 Knapsack Problem
ユーザー nasutarou1341nasutarou1341
提出日時 2023-06-30 21:35:20
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 657 bytes
コンパイル時間 325 ms
コンパイル使用メモリ 87,136 KB
実行使用メモリ 81,820 KB
最終ジャッジ日時 2023-09-21 15:26:40
合計ジャッジ時間 16,861 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
75,720 KB
testcase_01 AC 75 ms
71,288 KB
testcase_02 AC 77 ms
71,116 KB
testcase_03 AC 75 ms
71,424 KB
testcase_04 AC 84 ms
76,100 KB
testcase_05 AC 90 ms
76,184 KB
testcase_06 AC 82 ms
75,856 KB
testcase_07 AC 519 ms
77,308 KB
testcase_08 AC 75 ms
71,600 KB
testcase_09 AC 105 ms
76,036 KB
testcase_10 AC 195 ms
77,268 KB
testcase_11 AC 96 ms
76,952 KB
testcase_12 TLE -
testcase_13 TLE -
testcase_14 AC 2,868 ms
77,392 KB
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]]
      mi += 1
      if ni == N: break
print(ans)
0