結果

問題 No.2730 Two Types Luggage
ユーザー player
提出日時 2024-04-22 18:20:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 911 ms / 2,000 ms
コード長 494 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 268,372 KB
最終ジャッジ日時 2024-10-14 17:31:36
合計ジャッジ時間 16,982 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import accumulate

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

a.sort(reverse=True)
acc = [0] + list(accumulate(a))
ans = -1

for i in range(1 << m):
    weight = 0
    value = 0
    for j in range(m):
        if i >> j & 1:
            weight += b[j]
            value += c[j]
    if weight > w:
        continue
    ans = max(ans, value + acc[min(n, w - weight)])

print(ans)
0