結果

問題 No.2364 Knapsack Problem
ユーザー ra5anchorra5anchor
提出日時 2023-07-16 22:46:37
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 597 bytes
コンパイル時間 420 ms
コンパイル使用メモリ 81,760 KB
実行使用メモリ 66,028 KB
最終ジャッジ日時 2023-10-17 20:37:51
合計ジャッジ時間 2,534 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
61,868 KB
testcase_01 AC 48 ms
61,868 KB
testcase_02 AC 54 ms
63,940 KB
testcase_03 AC 54 ms
63,964 KB
testcase_04 AC 55 ms
63,964 KB
testcase_05 AC 57 ms
66,020 KB
testcase_06 AC 54 ms
63,964 KB
testcase_07 AC 53 ms
63,952 KB
testcase_08 AC 52 ms
63,928 KB
testcase_09 WA -
testcase_10 AC 51 ms
63,940 KB
testcase_11 AC 54 ms
63,960 KB
testcase_12 AC 57 ms
66,020 KB
testcase_13 AC 58 ms
66,020 KB
testcase_14 WA -
testcase_15 AC 58 ms
66,020 KB
testcase_16 AC 59 ms
66,020 KB
testcase_17 AC 59 ms
66,020 KB
testcase_18 AC 62 ms
66,028 KB
testcase_19 AC 58 ms
66,020 KB
testcase_20 AC 58 ms
66,020 KB
testcase_21 AC 59 ms
66,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

for i in range(M):
    A.append(-C[i])
    B.append(-D[i])

N += M


z = 10*W
DP = [[-10**18]*(20*W+1) for _ in range(N+1)]

DP[0][z] = 0

for i in range(N):
    for j in range(19*W):
        DP[i+1][j] = max(DP[i+1][j], DP[i][j])
        if j + A[i] >= 0:
            DP[i+1][j+A[i]] = max(DP[i+1][j+A[i]], DP[i][j] + B[i])

ans = -10**18
for i in range(z+W+1):
    ans = max(ans, DP[N][i])
print(ans)
# print(DP)
 
0