結果

問題 No.2730 Two Types Luggage
ユーザー LyricalMaestro
提出日時 2025-07-11 23:44:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 998 ms / 2,000 ms
コード長 822 bytes
コンパイル時間 393 ms
コンパイル使用メモリ 82,352 KB
実行使用メモリ 266,892 KB
最終ジャッジ日時 2025-07-11 23:44:39
合計ジャッジ時間 19,692 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

## https://yukicoder.me/problems/no/2730

MOD = 998244353

def main():
    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)
    cum_a = 0
    cum_a_list = [0] * N
    for i in range(N):
        cum_a += A[i]
        cum_a_list[i] = cum_a

    answer = -float("inf")
    for bit in range(2 ** M):
        b = 0
        c = 0
        for i in range(M):
            if bit & ( 1 << i) > 0:
                b += B[i]
                c += C[i]
        if b > W:
            continue

        w = W - b
        if w > 0:
            w0 = min(N, w)
            c += cum_a_list[w0 - 1]
        
        answer = max(answer, c)
    print(answer)


        




if __name__ == "__main__":
    main()
0