結果

問題 No.2730 Two Types Luggage
ユーザー 🦠みどりむし🦠みどりむし
提出日時 2024-04-04 23:10:06
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 877 bytes
コンパイル時間 2,584 ms
コンパイル使用メモリ 121,808 KB
実行使用メモリ 14,872 KB
最終ジャッジ日時 2024-04-04 23:10:16
合計ジャッジ時間 9,920 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 434 ms
13,660 KB
testcase_11 AC 478 ms
14,748 KB
testcase_12 AC 64 ms
6,676 KB
testcase_13 AC 240 ms
8,840 KB
testcase_14 AC 517 ms
14,872 KB
testcase_15 AC 187 ms
7,808 KB
testcase_16 AC 105 ms
6,676 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 185 ms
7,680 KB
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

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 = ws + cum_a[std::min<long>(w - ws, n)];

        if(ans < pro) ans = pro;
    }

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