結果

問題 No.2730 Two Types Luggage
ユーザー Tatsu_mrTatsu_mr
提出日時 2024-04-19 21:43:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 555 ms / 2,000 ms
コード長 964 bytes
コンパイル時間 2,012 ms
コンパイル使用メモリ 202,928 KB
実行使用メモリ 19,544 KB
最終ジャッジ日時 2024-04-19 21:43:52
合計ジャッジ時間 12,755 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 5 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 14 ms
5,376 KB
testcase_11 AC 337 ms
17,472 KB
testcase_12 AC 523 ms
19,304 KB
testcase_13 AC 270 ms
16,220 KB
testcase_14 AC 344 ms
17,408 KB
testcase_15 AC 149 ms
6,960 KB
testcase_16 AC 125 ms
9,748 KB
testcase_17 AC 434 ms
19,024 KB
testcase_18 AC 410 ms
18,408 KB
testcase_19 AC 36 ms
5,376 KB
testcase_20 AC 158 ms
10,340 KB
testcase_21 AC 320 ms
17,324 KB
testcase_22 AC 452 ms
19,260 KB
testcase_23 AC 45 ms
5,376 KB
testcase_24 AC 188 ms
10,820 KB
testcase_25 AC 347 ms
17,496 KB
testcase_26 AC 96 ms
7,052 KB
testcase_27 AC 320 ms
17,212 KB
testcase_28 AC 179 ms
10,616 KB
testcase_29 AC 430 ms
18,448 KB
testcase_30 AC 105 ms
5,376 KB
testcase_31 AC 263 ms
16,128 KB
testcase_32 AC 240 ms
11,808 KB
testcase_33 AC 516 ms
19,536 KB
testcase_34 AC 519 ms
19,544 KB
testcase_35 AC 555 ms
19,540 KB
testcase_36 AC 524 ms
19,540 KB
testcase_37 AC 520 ms
19,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, m;
    long long w;
    cin >> n >> m >> w;
    vector<long long> a(n), b(m), c(m);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> c[i];
    }
    sort(a.rbegin(), a.rend());
    vector<long long> sum = {0LL};
    long long cur = 0LL;
    for (int i = 0; i < n; i++) {
        cur += a[i];
        sum.push_back(cur);
    }
    long long ans = 0LL;
    for (int bit = 0; bit < (1 << m); bit++) {
        long long wgt = 0LL, val = 0LL;
        for (int i = 0; i < m; i++) {
            if (bit & (1 << i)) {
                wgt += b[i];
                val += c[i];
            }
        }
        if (wgt > w) {
            continue;
        }
        long long res = min(w - wgt, (long long)n);
        ans = max(ans, val + sum[res]);
    }
    cout << ans << endl;
}
0