結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 69 ms
6,676 KB
testcase_05 AC 18 ms
6,676 KB
testcase_06 AC 18 ms
6,676 KB
testcase_07 AC 34 ms
6,676 KB
testcase_08 AC 69 ms
6,676 KB
testcase_09 AC 3 ms
6,676 KB
testcase_10 AC 436 ms
13,660 KB
testcase_11 AC 486 ms
14,748 KB
testcase_12 AC 64 ms
6,676 KB
testcase_13 AC 232 ms
8,840 KB
testcase_14 AC 519 ms
14,872 KB
testcase_15 AC 188 ms
7,808 KB
testcase_16 AC 106 ms
6,676 KB
testcase_17 AC 51 ms
6,676 KB
testcase_18 AC 80 ms
6,676 KB
testcase_19 AC 136 ms
6,676 KB
testcase_20 AC 103 ms
6,676 KB
testcase_21 AC 70 ms
6,676 KB
testcase_22 AC 131 ms
6,676 KB
testcase_23 AC 39 ms
6,676 KB
testcase_24 AC 479 ms
13,720 KB
testcase_25 AC 265 ms
9,516 KB
testcase_26 AC 49 ms
6,676 KB
testcase_27 AC 232 ms
8,832 KB
testcase_28 AC 94 ms
6,676 KB
testcase_29 AC 414 ms
13,112 KB
testcase_30 AC 449 ms
13,896 KB
testcase_31 AC 186 ms
7,680 KB
testcase_32 AC 337 ms
11,400 KB
権限があれば一括ダウンロードができます

ソースコード

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