結果

問題 No.2329 Nafmo、イカサマをする
ユーザー 👑 NachiaNachia
提出日時 2023-05-28 14:36:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,379 bytes
コンパイル時間 761 ms
コンパイル使用メモリ 82,712 KB
実行使用メモリ 7,660 KB
最終ジャッジ日時 2023-08-27 10:10:28
合計ジャッジ時間 4,515 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector<long long> A1;
vector<long long> A2;
vector<long long> B2;

int main() {
    long long N,M,K; cin >> N >> M >> K;
    A1.resize(N);
    for(int i=0; i<N; i++) cin >> A1[i];

    if(K/2 >= 0) A2.push_back(0);
    if(K/2 >= 1) for(int i=0; i<N; i++) A2.push_back(A1[i]);
    if(K/2 >= 2) for(int i=0; i<N; i++) for(int j=i; j<N; j++) A2.push_back(A1[i] + A1[j]);
    if(K/2 >= 3) for(int i=0; i<N; i++) for(int j=i; j<N; j++) for(int k=j; k<N; k++) A2.push_back(A1[i] + A1[j] + A1[k]);
    if((K+1)/2 >= 0) B2.push_back(0);
    if((K+1)/2 >= 1) for(int i=0; i<N; i++) B2.push_back(A1[i]);
    if((K+1)/2 >= 2) for(int i=0; i<N; i++) for(int j=i; j<N; j++) B2.push_back(A1[i] + A1[j]);
    if((K+1)/2 >= 3) for(int i=0; i<N; i++) for(int j=i; j<N; j++) for(int k=j; k<N; k++) B2.push_back(A1[i] + A1[j] + A1[k]);
    sort(A2.begin(), A2.end());
    sort(B2.begin(), B2.end());

    long long ans = 0;
    long long q = B2.size()-1;
    while(B2[q] > M) q--;
    for(std::size_t p=0; p<A2.size(); p++){
        while(A2[p]+B2[q] > M) q--;
        if(ans < A2[p] + B2[q]) ans = A2[p] + B2[q];
    }
    cout << ans << '\n';
    return 0;
}


struct ios_do_not_sync{
    ios_do_not_sync(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(nullptr);
    }
} ios_do_not_sync_instance;
0