結果

問題 No.2329 Nafmo、イカサマをする
ユーザー erbowlerbowl
提出日時 2023-07-07 08:12:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,357 bytes
コンパイル時間 2,477 ms
コンパイル使用メモリ 209,112 KB
実行使用メモリ 32,016 KB
最終ジャッジ日時 2023-09-28 08:28:43
合計ジャッジ時間 7,308 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    ll n,m,k;
    std::cin >> n>>m>>k;
    vector<ll> a(n);
    vector<ll> b,c;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        if(i<n/3){
            b.push_back(a[i]);
        }else{
            c.push_back(a[i]);
        }
        //     // d.push_back(a[i]);
        // }
    }
    
    vector<set<ll>> v1(k+1);
    vector<set<ll>> v2(k+1);
    // vector<set<ll>> v3(k+1);
    v1[0].insert(0);
    v2[0].insert(0);
    // v3[0].insert(0);
    for (auto e : b) {
        for (int i = 0; i < k; i++) {
            for (auto ee : v1[i]) {
                v1[i+1].insert(ee+e);
            }
        }
    }
    
    for (auto e : c) {
        for (int i = 0; i < k; i++) {
            for (auto ee : v2[i]) {
                v2[i+1].insert(ee+e);
            }
        }
    }
    ll ans = 0;
    
    for (int i = 0; i <= k; i++) {
        for (int j = 0; j <= k; j++) {
            if(i+j>k)continue;
            for (auto e1 : v1[i]) {
                if(e1>m)break;
                auto it = v2[j].upper_bound(m-e1);
                if(it==v2[j].begin())continue;
                it--;
                ans = max(ans, e1+*it);
            }
        }
    }
    
    std::cout << ans << std::endl;
    
}
0