結果

問題 No.2730 Two Types Luggage
コンテスト
ユーザー norioc
提出日時 2025-10-23 02:56:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 895 ms / 2,000 ms
コード長 528 bytes
コンパイル時間 348 ms
コンパイル使用メモリ 82,656 KB
実行使用メモリ 269,124 KB
最終ジャッジ日時 2025-10-23 02:56:27
合計ジャッジ時間 16,070 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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()))

acc = list(accumulate(sorted(A, reverse=True)))
ans = 0
for i in range(1 << M):
    w = v = 0
    for j in range(M):
        if ~i & (1 << j): continue
        w += B[j]
        v += C[j]
        if w > W: break

    if w <= W:
        cnt = W-w
        if cnt > 0:
            v += acc[min(cnt-1, len(acc)-1)]
        ans = max(ans, v)

print(ans)
0