結果

問題 No.2730 Two Types Luggage
コンテスト
ユーザー イルカ
提出日時 2024-06-13 05:06:48
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 620 ms / 2,000 ms
+ 827µs
コード長 784 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 238 ms
コンパイル使用メモリ 96,104 KB
実行使用メモリ 312,736 KB
最終ジャッジ日時 2026-07-26 11:13:11
合計ジャッジ時間 14,689 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import itertools

# M<=20よりMについて全探索
N, M, W = map(int, input().split())
A = sorted(list(map(int, input().split())))[::-1]
As = list(itertools.accumulate(A))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
cnt = []

for i in range(2**M):
    ws = 0
    ps = 0
    flag = True
    for j in range(M):
        if ((i >> j) & 1):
            ws += B[j]
            ps += C[j]
            if ws > W:
                flag = False
                break
    if flag:
        if ws == W:
            cnt.append(ps)
        else:
            remaining_weight = W - ws
            if remaining_weight - 1 < len(A):
                cnt.append(ps + As[remaining_weight - 1])
            else:
                cnt.append(ps + As[-1])

print(max(cnt))
"🐬"
0