結果

問題 No.2686 商品券の使い道
ユーザー eve__fuyukieve__fuyuki
提出日時 2024-03-26 13:28:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,427 bytes
コンパイル時間 2,072 ms
コンパイル使用メモリ 206,132 KB
実行使用メモリ 40,220 KB
最終ジャッジ日時 2024-03-26 13:28:53
合計ジャッジ時間 7,313 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 36 ms
12,544 KB
testcase_03 AC 36 ms
12,544 KB
testcase_04 AC 36 ms
12,544 KB
testcase_05 AC 35 ms
12,544 KB
testcase_06 AC 35 ms
12,544 KB
testcase_07 AC 36 ms
12,544 KB
testcase_08 AC 37 ms
12,544 KB
testcase_09 AC 36 ms
12,544 KB
testcase_10 AC 36 ms
12,544 KB
testcase_11 AC 35 ms
12,544 KB
testcase_12 AC 37 ms
12,544 KB
testcase_13 AC 35 ms
12,544 KB
testcase_14 AC 35 ms
12,544 KB
testcase_15 AC 35 ms
12,544 KB
testcase_16 AC 35 ms
12,544 KB
testcase_17 AC 35 ms
12,544 KB
testcase_18 AC 34 ms
12,544 KB
testcase_19 AC 35 ms
12,544 KB
testcase_20 AC 35 ms
12,544 KB
testcase_21 AC 36 ms
12,544 KB
testcase_22 AC 36 ms
12,544 KB
testcase_23 AC 35 ms
12,544 KB
testcase_24 AC 35 ms
12,544 KB
testcase_25 AC 35 ms
12,544 KB
testcase_26 AC 36 ms
12,544 KB
testcase_27 AC 36 ms
12,544 KB
testcase_28 AC 35 ms
12,544 KB
testcase_29 AC 133 ms
40,220 KB
testcase_30 WA -
testcase_31 AC 141 ms
40,220 KB
testcase_32 AC 134 ms
40,220 KB
testcase_33 AC 135 ms
40,220 KB
testcase_34 AC 134 ms
40,220 KB
testcase_35 AC 134 ms
40,220 KB
testcase_36 AC 134 ms
40,220 KB
testcase_37 AC 134 ms
40,220 KB
testcase_38 AC 134 ms
40,220 KB
testcase_39 AC 136 ms
40,220 KB
testcase_40 AC 142 ms
40,220 KB
testcase_41 AC 135 ms
40,220 KB
testcase_42 AC 135 ms
40,220 KB
testcase_43 AC 135 ms
40,220 KB
testcase_44 AC 135 ms
40,220 KB
testcase_45 AC 133 ms
40,220 KB
testcase_46 AC 135 ms
40,220 KB
evil_random20_1.txt AC 138 ms
40,220 KB
evil_random20_2.txt AC 142 ms
40,220 KB
evil_random20_3.txt AC 136 ms
40,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
void fast_io() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

int main() {
    fast_io();
    int n;
    long long m, q;
    cin >> n >> m >> q;
    vector<long long> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    vector<long long> asum(1 << n), bsum(1 << n);
    vector<long long> f(1 << n), g(1 << n);
    for (int i = 0; i < (1 << n); i++) {
        for (int j = 0; j < n; j++) {
            if (i & (1 << j)) {
                asum[i] += a[j];
                bsum[i] += b[j];
            }
        }
        if (asum[i] <= m) {
            f[i] = 1;
        }
        if (asum[i] <= q) {
            g[i] = 1;
        }
    }
    for (int i = 0; i < n; i++) {
        for (int x = 0; x < (1 << n); x++) {
            if (x & (1 << i)) {
                f[x] = f[x] + f[x ^ (1 << i)];
                g[x] = g[x] + g[x ^ (1 << i)];
            }
        }
    }
    vector<int> h(1 << n);
    for (int i = 0; i < (1 << n); i++) {
        h[i] = f[i] * g[i];
    }
    for (int i = 0; i < n; i++) {
        for (int x = 0; x < (1 << n); x++) {
            if (x & (1 << i)) {
                h[x] = h[x] - h[x ^ (1 << i)];
            }
        }
    }
    long long ans = 0;
    for (int i = 0; i < (1 << n); i++) {
        if (h[i] > 0) {
            ans = max(ans, bsum[i]);
        }
    }
    cout << ans << endl;
}
0