結果

問題 No.2686 商品券の使い道
ユーザー GOTKAKOGOTKAKO
提出日時 2024-03-20 22:28:54
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 894 bytes
コンパイル時間 2,674 ms
コンパイル使用メモリ 202,296 KB
実行使用メモリ 22,016 KB
最終ジャッジ日時 2024-03-20 22:29:11
合計ジャッジ時間 17,042 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 454 ms
6,548 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 464 ms
6,548 KB
testcase_08 AC 451 ms
6,548 KB
testcase_09 AC 461 ms
6,548 KB
testcase_10 AC 500 ms
6,548 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 26 ms
6,548 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 26 ms
6,548 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 676 ms
6,548 KB
testcase_24 WA -
testcase_25 AC 473 ms
6,548 KB
testcase_26 WA -
testcase_27 AC 26 ms
6,548 KB
testcase_28 AC 154 ms
6,548 KB
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);

    int N,M,Q; cin >> N >> M >> Q;
    int A[N],B[N];
    for(int i=0; i<N; i++) cin >> A[i] >> B[i];

    int n2 = 1<<N,inf = max(M,Q);
    int S[n2];
    long long S2[n2];
    for(int i=0; i<n2; i++){
        S[i] = 0; S2[i] = 0;
        for(int k=0; k<N; k++){
            if(!(i&(1<<k))) continue;
            S[i] += A[k];
            S2[i] += B[k];
            if(S[i] > inf) break;
        }
    }

    long long answer = 0;
    for(int i=0; i<n2; i++){
        if(S[i] <= M || S[i] <= Q){answer = max(answer,S2[i]); continue;}

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