結果

問題 No.2329 Nafmo、イカサマをする
ユーザー Naoto FujiwaraNaoto Fujiwara
提出日時 2023-05-29 16:59:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,476 bytes
コンパイル時間 981 ms
コンパイル使用メモリ 93,004 KB
実行使用メモリ 14,008 KB
最終ジャッジ日時 2023-08-27 23:45:51
合計ジャッジ時間 2,467 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 1 ms
4,380 KB
testcase_25 WA -
testcase_26 AC 2 ms
4,380 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 2 ms
4,380 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

//TLE
#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<queue>
#include<tuple>
#include<cmath>
using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
typedef pair<ll,int> P;
typedef pair<int,P> PP;
const ll MOD=998244353;




int main(){
    int N,M,K;
    cin>>N>>M>>K;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    A.push_back(0);

    vector<ll> tmp;

    auto dfs=[&](auto f,int idx, int n)->set<ll>{

        if(idx==n){
            return set<ll>{0};
        }

        set<ll> tmp=f(f,idx+1,n);
        set<ll> tmpst; //被りがでないように
        for(ll v:tmp){
            for(ll a:A){
                if(v+a>M) continue;
                tmpst.insert(v+a);
            }
        }
        

        set<ll> res;
        for(ll v:tmpst){
            //res.push_back(v);
            res.insert(v);
        }

        return res;
    };

    set<ll> res1=dfs(dfs,0,K/2);
    set<ll> res2=dfs(dfs,0,K-K/2);

    ll ans=0;

    for(ll v1:res1){
        ll v=v1+(*res2.rbegin());
        if(v>M) continue;
        ans=max(ans, v );
    }

    for(ll v2:res2){
        ll v=v2+(*res1.rbegin());
        if(v>M) continue;
        ans=max(ans, v );
    }



    /*
    for(ll v1:res1){
        for(ll v2:res2){
            if(v1+v2>M) continue;

            ans=max(ans,v1+v2);
        }
    }
    */

    cout<<ans<<endl;

   
   


}
0