結果

問題 No.2329 Nafmo、イカサマをする
ユーザー t98slidert98slider
提出日時 2023-05-28 15:40:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 122 ms / 2,000 ms
コード長 994 bytes
コンパイル時間 1,840 ms
コンパイル使用メモリ 179,288 KB
実行使用メモリ 12,712 KB
最終ジャッジ日時 2023-08-27 12:41:12
合計ジャッジ時間 3,911 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,384 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 4 ms
4,380 KB
testcase_19 AC 20 ms
5,048 KB
testcase_20 AC 6 ms
4,380 KB
testcase_21 AC 25 ms
5,200 KB
testcase_22 AC 4 ms
4,376 KB
testcase_23 AC 25 ms
5,116 KB
testcase_24 AC 10 ms
4,380 KB
testcase_25 AC 6 ms
4,376 KB
testcase_26 AC 8 ms
4,376 KB
testcase_27 AC 6 ms
4,380 KB
testcase_28 AC 4 ms
4,380 KB
testcase_29 AC 7 ms
4,380 KB
testcase_30 AC 3 ms
4,376 KB
testcase_31 AC 32 ms
7,884 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 6 ms
4,376 KB
testcase_34 AC 11 ms
4,380 KB
testcase_35 AC 3 ms
4,380 KB
testcase_36 AC 56 ms
7,708 KB
testcase_37 AC 17 ms
5,400 KB
testcase_38 AC 98 ms
12,712 KB
testcase_39 AC 102 ms
12,456 KB
testcase_40 AC 100 ms
11,748 KB
testcase_41 AC 122 ms
12,256 KB
testcase_42 AC 101 ms
11,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n);
    for(auto &&v : a) cin >> v;
    vector<vector<ll>> dp(4);
    dp[0].push_back(0);
    dp[1] = a;
    for(int i = 1; i < 3; i++){
        for(int j = 0; j < dp[i].size(); j++){
            for(int k = 0; k < n; k++){
                dp[i + 1].emplace_back(dp[i][j] + a[k]);
            }
        }
    }
    for(int i = 0; i < 4; i++){
        sort(dp[i].begin(), dp[i].end());
    }
    vector<pair<int,int>> b = {{1, 0}, {2, 0}, {3, 0}, {1, 3}, {2, 3}, {3, 3}};
    ll ans = 0;
    for(int i = 0; i < k; i++){
        int s, t;
        tie(s, t) = b[i];
        for(int j = 0; j < dp[s].size(); j++){
            int k = upper_bound(dp[t].begin(), dp[t].end(), m - dp[s][j]) - dp[t].begin() - 1;
            if(k >= 0) ans = max(ans, dp[s][j] + dp[t][k]);
        }
    }
    cout << ans << '\n';
}
0