結果

問題 No.2329 Nafmo、イカサマをする
ユーザー erbowlerbowl
提出日時 2023-07-07 08:24:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,835 bytes
コンパイル時間 2,054 ms
コンパイル使用メモリ 210,588 KB
実行使用メモリ 5,780 KB
最終ジャッジ日時 2023-09-28 08:40:26
合計ジャッジ時間 3,603 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 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,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 WA -
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 4 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 4 ms
4,376 KB
testcase_22 WA -
testcase_23 AC 4 ms
4,380 KB
testcase_24 AC 3 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 3 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 5 ms
4,380 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 3 ms
4,380 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 7 ms
4,416 KB
testcase_37 AC 4 ms
4,376 KB
testcase_38 AC 12 ms
5,536 KB
testcase_39 AC 13 ms
5,776 KB
testcase_40 AC 14 ms
5,780 KB
testcase_41 AC 18 ms
5,512 KB
testcase_42 AC 13 ms
5,536 KB
権限があれば一括ダウンロードができます

ソースコード

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/2){
            b.push_back(a[i]);
        }else{
            c.push_back(a[i]);
        }
        //     // d.push_back(a[i]);
        // }
    }
    
    vector<set<ll>> v1(7);
    vector<set<ll>> v2(7);
    // 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 < 3; i++) {
            for (auto ee : v1[i]) {
                v1[i+1].insert(ee+e);
            }
        }
    }
    
    for (auto e : c) {
        for (int i = 0; i < 3; i++) {
            for (auto ee : v2[i]) {
                v2[i+1].insert(ee+e);
            }
        }
    }
    ll ans = 0;
    
    for (int i = 0; i <= 3; i++) {
        for (int j = 0; j <= 3; 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);
            }
            for (auto e1 : v1[i]) {
                if(e1>m)break;
                auto it = v1[j].upper_bound(m-e1);
                if(it==v1[j].begin())continue;
                it--;
                ans = max(ans, e1+*it);
            }
            for (auto e1 : v2[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