結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 2 ms
4,376 KB
testcase_25 WA -
testcase_26 AC 2 ms
4,376 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 2 ms
4,380 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,376 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);

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

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

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

                if(v+a<=M){
                    tmpst.insert(v+a);
                }
            }
        }

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

        return res;
    };

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

    ll ans=0;

    for(ll v:res1){
        if(v+res2.back()<=M){
            ans=max(ans,res2.back()+v);
        }
    }

    for(ll v:res2){
        if(v+res1.back()<=M){ 
            ans=max(ans,res1.back()+v);
        }
    }

   

    cout<<ans<<endl;

   
   


}
0