結果

問題 No.2329 Nafmo、イカサマをする
ユーザー KKT89KKT89
提出日時 2023-05-28 14:15:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 192 ms / 2,000 ms
コード長 1,698 bytes
コンパイル時間 3,566 ms
コンパイル使用メモリ 217,292 KB
実行使用メモリ 19,444 KB
最終ジャッジ日時 2023-08-27 09:23:57
合計ジャッジ時間 4,945 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 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 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 4 ms
4,376 KB
testcase_19 AC 15 ms
6,520 KB
testcase_20 AC 8 ms
4,380 KB
testcase_21 AC 16 ms
7,236 KB
testcase_22 AC 5 ms
4,376 KB
testcase_23 AC 16 ms
9,604 KB
testcase_24 AC 7 ms
4,912 KB
testcase_25 AC 4 ms
4,376 KB
testcase_26 AC 5 ms
4,772 KB
testcase_27 AC 5 ms
4,376 KB
testcase_28 AC 4 ms
4,380 KB
testcase_29 AC 10 ms
4,376 KB
testcase_30 AC 3 ms
4,380 KB
testcase_31 AC 19 ms
10,580 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 4 ms
4,376 KB
testcase_34 AC 7 ms
4,908 KB
testcase_35 AC 4 ms
4,376 KB
testcase_36 AC 90 ms
11,416 KB
testcase_37 AC 12 ms
6,284 KB
testcase_38 AC 49 ms
19,312 KB
testcase_39 AC 125 ms
19,316 KB
testcase_40 AC 56 ms
19,444 KB
testcase_41 AC 192 ms
19,264 KB
testcase_42 AC 57 ms
19,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}
inline double time() {
    return static_cast<long double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m,k; cin >> n >> m >> k;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    n++; a.push_back(0);
    vector<ll> v,vv;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            for (int l = 0; l < n; ++l) {
                {
                    ll cost = 0;
                    cost += (k/2 >= 1 ? a[i] : 0);
                    cost += (k/2 >= 2 ? a[j] : 0);
                    cost += (k/2 >= 3 ? a[l] : 0);
                    v.push_back(cost);
                }
                {
                    ll cost = 0;
                    cost += (k-k/2 >= 1 ? a[i] : 0);
                    cost += (k-k/2 >= 2 ? a[j] : 0);
                    cost += (k-k/2 >= 3 ? a[l] : 0);
                    vv.push_back(cost);
                }
            }
        }
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    sort(vv.begin(), vv.end());
    vv.erase(unique(vv.begin(), vv.end()), vv.end());

    ll res = 0;
    for (auto p : v) {
        if (p > m) break;
        auto it = upper_bound(vv.begin(), vv.end(), m-p);
        it--;
        res = max(res, p+*it);
    }
    cout << res << endl;
}
0