結果

問題 No.2364 Knapsack Problem
ユーザー ra5anchorra5anchor
提出日時 2023-07-16 22:42:52
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 584 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 81,672 KB
実行使用メモリ 65,912 KB
最終ジャッジ日時 2023-10-17 20:33:27
合計ジャッジ時間 2,212 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
59,684 KB
testcase_01 AC 47 ms
59,684 KB
testcase_02 AC 51 ms
63,836 KB
testcase_03 AC 53 ms
63,856 KB
testcase_04 AC 50 ms
63,828 KB
testcase_05 AC 53 ms
63,840 KB
testcase_06 AC 53 ms
63,856 KB
testcase_07 AC 52 ms
63,856 KB
testcase_08 AC 49 ms
61,772 KB
testcase_09 WA -
testcase_10 AC 48 ms
61,780 KB
testcase_11 AC 52 ms
63,844 KB
testcase_12 AC 54 ms
63,860 KB
testcase_13 AC 55 ms
63,860 KB
testcase_14 WA -
testcase_15 AC 54 ms
63,860 KB
testcase_16 AC 54 ms
63,860 KB
testcase_17 AC 54 ms
63,860 KB
testcase_18 AC 55 ms
65,912 KB
testcase_19 AC 55 ms
63,860 KB
testcase_20 AC 54 ms
63,860 KB
testcase_21 AC 55 ms
63,860 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

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

DP[0][0] = 0

for i in range(N):
    for j in range(9*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(W+1):
    ans = max(ans, DP[N][i])
print(ans)
# print(DP)
 
0