結果

問題 No.2686 商品券の使い道
ユーザー GOTKAKOGOTKAKO
提出日時 2024-03-20 22:02:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 859 bytes
コンパイル時間 2,184 ms
コンパイル使用メモリ 206,764 KB
実行使用メモリ 19,852 KB
最終ジャッジ日時 2024-03-20 22:02:30
合計ジャッジ時間 6,234 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 25 ms
7,552 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 26 ms
7,552 KB
testcase_17 WA -
testcase_18 AC 25 ms
7,552 KB
testcase_19 WA -
testcase_20 AC 26 ms
7,552 KB
testcase_21 AC 25 ms
7,552 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 25 ms
7,552 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 94 ms
19,852 KB
testcase_31 WA -
testcase_32 AC 91 ms
19,852 KB
testcase_33 AC 94 ms
19,852 KB
testcase_34 WA -
testcase_35 AC 93 ms
19,852 KB
testcase_36 AC 90 ms
19,852 KB
testcase_37 AC 91 ms
19,852 KB
testcase_38 AC 92 ms
19,852 KB
testcase_39 AC 91 ms
19,852 KB
testcase_40 WA -
testcase_41 AC 90 ms
19,852 KB
testcase_42 WA -
testcase_43 AC 92 ms
19,852 KB
testcase_44 AC 92 ms
19,852 KB
testcase_45 WA -
testcase_46 WA -
evil_random20_1.txt WA -
evil_random20_2.txt WA -
evil_random20_3.txt WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    long long N,M,Q; cin >> N >> M >> Q;
    vector<long long> A(N),B(N);
    for(int i=0; i<N; i++) cin >> A.at(i) >> B.at(i);

    int n2 = 1<<N;
    vector<bool> buy(n2);
    vector<long long> S(n2),S2(n2);
    for(int i=0; i<n2; i++){
        for(int k=0; k<N; k++){
            if(!(i&(1<<k))) continue;
            S.at(i) += A.at(k);
            S2.at(i) += B.at(k);
        }
        if(S.at(i) <= M) buy.at(i) = true;
    }

    long long answer = 0;
    for(int i=0; i<n2; i++){
        if(buy.at(i)){answer = max(answer,S2.at(i)); continue;}

        int pos = i^(n2-1);
        if(buy.at(pos) == false) continue;
        if(S2.at(pos) > Q) continue;
        answer = max(answer,S2.at(i));  
    }
    cout << answer << endl;
}
0