結果
問題 | No.2364 Knapsack Problem |
ユーザー | nasutarou1341 |
提出日時 | 2023-06-30 21:33:59 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 643 bytes |
コンパイル時間 | 1,157 ms |
コンパイル使用メモリ | 86,956 KB |
実行使用メモリ | 81,712 KB |
最終ジャッジ日時 | 2023-09-21 15:23:25 |
合計ジャッジ時間 | 11,560 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 74 ms
71,704 KB |
testcase_01 | AC | 74 ms
71,472 KB |
testcase_02 | AC | 76 ms
71,472 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 90 ms
76,120 KB |
testcase_06 | WA | - |
testcase_07 | AC | 1,298 ms
77,200 KB |
testcase_08 | AC | 74 ms
71,524 KB |
testcase_09 | AC | 112 ms
76,624 KB |
testcase_10 | AC | 201 ms
77,184 KB |
testcase_11 | AC | 93 ms
76,880 KB |
testcase_12 | TLE | - |
testcase_13 | TLE | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
ソースコード
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]] if ni == N: break print(ans)