結果

問題 No.2686 商品券の使い道
ユーザー aradarad
提出日時 2024-03-01 08:15:43
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,086 bytes
コンパイル時間 3,151 ms
コンパイル使用メモリ 262,484 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-19 00:38:02
合計ジャッジ時間 25,610 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 1 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 1,648 ms
6,676 KB
testcase_12 AC 67 ms
6,676 KB
testcase_13 AC 2,883 ms
6,676 KB
testcase_14 AC 450 ms
6,676 KB
testcase_15 AC 160 ms
6,676 KB
testcase_16 AC 1,802 ms
6,676 KB
testcase_17 AC 88 ms
6,676 KB
testcase_18 AC 625 ms
6,676 KB
testcase_19 AC 658 ms
6,676 KB
testcase_20 AC 2,884 ms
6,676 KB
testcase_21 AC 2,624 ms
6,676 KB
testcase_22 AC 12 ms
6,676 KB
testcase_23 AC 5 ms
6,676 KB
testcase_24 AC 1,148 ms
6,676 KB
testcase_25 AC 5 ms
6,676 KB
testcase_26 AC 462 ms
6,676 KB
testcase_27 AC 1,921 ms
6,676 KB
testcase_28 AC 4 ms
6,676 KB
testcase_29 AC 31 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;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
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);
    vector<pair<ll,ll>> x(n);
    for(ll i = 0;i < n;i++){
        cin >> x[i].first >> x[i].second;
    }
    sort(x.rbegin(),x.rend());
    for(ll i = 0;i < n;i++){
        a[i] = x[i].first;
        b[i] = x[i].second;
    }
    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