結果

問題 No.2730 Two Types Luggage
ユーザー eve__fuyukieve__fuyuki
提出日時 2024-04-19 21:26:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 316 ms / 2,000 ms
コード長 1,078 bytes
コンパイル時間 2,397 ms
コンパイル使用メモリ 201,368 KB
実行使用メモリ 18,936 KB
最終ジャッジ日時 2024-04-19 21:27:22
合計ジャッジ時間 9,444 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 6 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 2 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 8 ms
5,376 KB
testcase_11 AC 173 ms
14,848 KB
testcase_12 AC 316 ms
18,560 KB
testcase_13 AC 138 ms
12,544 KB
testcase_14 AC 174 ms
14,848 KB
testcase_15 AC 116 ms
6,272 KB
testcase_16 AC 65 ms
7,424 KB
testcase_17 AC 225 ms
18,056 KB
testcase_18 AC 214 ms
16,732 KB
testcase_19 AC 19 ms
5,376 KB
testcase_20 AC 82 ms
8,476 KB
testcase_21 AC 165 ms
14,208 KB
testcase_22 AC 231 ms
18,560 KB
testcase_23 AC 26 ms
5,376 KB
testcase_24 AC 97 ms
9,600 KB
testcase_25 AC 178 ms
14,848 KB
testcase_26 AC 48 ms
6,272 KB
testcase_27 AC 164 ms
14,308 KB
testcase_28 AC 90 ms
9,200 KB
testcase_29 AC 207 ms
16,896 KB
testcase_30 AC 92 ms
5,376 KB
testcase_31 AC 141 ms
12,136 KB
testcase_32 AC 122 ms
11,392 KB
testcase_33 AC 314 ms
18,688 KB
testcase_34 AC 305 ms
18,936 KB
testcase_35 AC 305 ms
18,688 KB
testcase_36 AC 305 ms
18,816 KB
testcase_37 AC 315 ms
18,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}
int main() {
    fast_io();
    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> cum(n + 1);
    for (int i = 0; i < n; i++) {
        cum[i + 1] = cum[i] + a[i];
    }
    long long ans = 0;
    for (int st = 0; st < (1 << m); st++) {
        long long sum = 0, weight = 0;
        for (int i = 0; i < m; i++) {
            if (st & (1 << i)) {
                sum += c[i];
                weight += b[i];
            }
        }
        if (weight > w) {
            continue;
        }
        if (weight + n <= w) {
            ans = max(ans, sum + cum[n]);
        } else {
            ans = max(ans, sum + cum[w - weight]);
        }
    }
    cout << ans << endl;
}
0