結果

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

テストケース

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

ソースコード

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 != 0) 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