結果

問題 No.2329 Nafmo、イカサマをする
ユーザー erbowlerbowl
提出日時 2023-07-07 08:25:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,076 bytes
コンパイル時間 2,294 ms
コンパイル使用メモリ 212,556 KB
実行使用メモリ 5,632 KB
最終ジャッジ日時 2024-07-21 03:11:39
合計ジャッジ時間 3,744 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 WA -
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 WA -
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 5 ms
5,376 KB
testcase_20 AC 3 ms
5,376 KB
testcase_21 AC 4 ms
5,376 KB
testcase_22 WA -
testcase_23 AC 5 ms
5,376 KB
testcase_24 AC 3 ms
5,376 KB
testcase_25 AC 3 ms
5,376 KB
testcase_26 AC 3 ms
5,376 KB
testcase_27 AC 3 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 3 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 5 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 3 ms
5,376 KB
testcase_34 AC 3 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 8 ms
5,376 KB
testcase_37 AC 4 ms
5,376 KB
testcase_38 AC 13 ms
5,632 KB
testcase_39 AC 14 ms
5,632 KB
testcase_40 AC 14 ms
5,632 KB
testcase_41 AC 19 ms
5,632 KB
testcase_42 AC 15 ms
5,632 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 : v2[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 : 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