結果

問題 No.2730 Two Types Luggage
ユーザー 🦠みどりむし🦠みどりむし
提出日時 2024-04-04 23:13:06
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 877 bytes
コンパイル時間 1,174 ms
コンパイル使用メモリ 121,580 KB
実行使用メモリ 15,104 KB
最終ジャッジ日時 2024-10-01 00:39:10
合計ジャッジ時間 6,504 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7 WA * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <ranges>

signed main() {
    int n, m, w; std::cin >> n >> m >> w;
    std::vector<int> a(n), b(m), c(m);

    for(auto& v : a) std::cin >> v;
    for(auto& v : b) std::cin >> v;
    for(auto& v : c) std::cin >> v;

    std::ranges::sort(a, [&](int x, int y) { return y < x; });
    std::vector<long> cum_a(n + 1);
    for(const int i : std::views::iota(0, n)) cum_a[i + 1] = cum_a[i] + a[i];

    long ans = 0;

    for(const int x : std::views::iota(0U, 1U << m)) {
        long ws = 0, vs = 0;
        for(const int i : std::views::iota(0, m)) {
            if((x >> i) & 1) continue;
            ws += b[i];
            vs += c[i];
        }

        if(ws > w) continue;

        long pro = vs + cum_a[std::min<long>(w - ws, n)];

        if(ans < pro) ans = pro;
    }

    std::cout << ans << "\n";
}
0