結果

問題 No.2686 商品券の使い道
ユーザー GOTKAKOGOTKAKO
提出日時 2024-03-20 22:06:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 922 bytes
コンパイル時間 2,268 ms
コンパイル使用メモリ 206,776 KB
実行使用メモリ 26,400 KB
最終ジャッジ日時 2024-03-20 22:06:44
合計ジャッジ時間 20,929 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,480 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 679 ms
7,552 KB
testcase_03 AC 731 ms
7,552 KB
testcase_04 AC 753 ms
7,552 KB
testcase_05 AC 693 ms
7,552 KB
testcase_06 AC 733 ms
7,552 KB
testcase_07 AC 692 ms
7,552 KB
testcase_08 AC 702 ms
7,552 KB
testcase_09 AC 686 ms
7,552 KB
testcase_10 AC 728 ms
7,552 KB
testcase_11 AC 80 ms
7,552 KB
testcase_12 AC 623 ms
7,552 KB
testcase_13 AC 29 ms
7,552 KB
testcase_14 AC 337 ms
7,552 KB
testcase_15 AC 783 ms
7,552 KB
testcase_16 AC 46 ms
7,552 KB
testcase_17 AC 949 ms
7,552 KB
testcase_18 AC 75 ms
7,552 KB
testcase_19 AC 109 ms
7,552 KB
testcase_20 AC 30 ms
7,552 KB
testcase_21 AC 30 ms
7,552 KB
testcase_22 AC 806 ms
7,552 KB
testcase_23 AC 892 ms
7,552 KB
testcase_24 AC 198 ms
7,552 KB
testcase_25 AC 682 ms
7,552 KB
testcase_26 AC 350 ms
7,552 KB
testcase_27 AC 29 ms
7,552 KB
testcase_28 WA -
testcase_29 TLE -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
evil_random20_1.txt -- -
evil_random20_2.txt -- -
evil_random20_3.txt -- -
権限があれば一括ダウンロードができます

ソースコード

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;}

        for(int k=i; k>0; k=(k-1)&i){
            if(buy.at(k) == false) continue;
            int left = i-k;
            if(S.at(left) > Q) continue;
            answer = max(answer,S2.at(i)); break;
        }
    }
    cout << answer << endl;
}
0