結果

問題 No.2686 商品券の使い道
ユーザー aradarad
提出日時 2024-03-01 08:11:22
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 831 bytes
コンパイル時間 2,868 ms
コンパイル使用メモリ 247,508 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-19 00:37:34
合計ジャッジ時間 31,641 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2,195 ms
6,676 KB
testcase_12 AC 110 ms
6,676 KB
testcase_13 TLE -
testcase_14 AC 677 ms
6,676 KB
testcase_15 AC 289 ms
6,676 KB
testcase_16 AC 2,277 ms
6,676 KB
testcase_17 AC 172 ms
6,676 KB
testcase_18 AC 838 ms
6,676 KB
testcase_19 AC 897 ms
6,676 KB
testcase_20 TLE -
testcase_21 TLE -
testcase_22 AC 30 ms
6,676 KB
testcase_23 AC 8 ms
6,676 KB
testcase_24 AC 1,695 ms
6,676 KB
testcase_25 AC 15 ms
6,676 KB
testcase_26 AC 714 ms
6,676 KB
testcase_27 AC 2,537 ms
6,676 KB
testcase_28 AC 5 ms
6,676 KB
testcase_29 AC 60 ms
6,676 KB
testcase_30 TLE -
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;
using ll = long long;
const ll INF = 1e18;

//O(3^n)

int main(){
    ll n,m,q;
    cin >> n >> m >> q;
    vector<ll> a(n),b(n);
    for(ll i = 0;i < n;i++){
        cin >> a[i] >> b[i];
    }
    ll msum = 0,qsum = 0,val = 0,ans = 0;
    auto rec = [&](auto &rec,ll i) -> void {
        if(i==n){
            ans = max(ans,val);
            return;
        }
        rec(rec,i+1);
        if(msum+a[i] <= m){
            msum += a[i];
            val += b[i];
            rec(rec,i+1);
            msum -= a[i];
            val -= b[i];
        }
        if(qsum+a[i] <= q){
            qsum += a[i];
            val += b[i];
            rec(rec,i+1);
            qsum -= a[i];
            val -= b[i];
        }
        return;
    };
    rec(rec,0);
    cout << ans << endl;
}
    
0