結果

問題 No.617 Nafmo、買い出しに行く
ユーザー 👑 naipianaipia
提出日時 2018-05-22 02:10:59
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 595 bytes
コンパイル時間 1,402 ms
コンパイル使用メモリ 153,236 KB
実行使用メモリ 8,872 KB
最終ジャッジ日時 2023-09-11 01:10:32
合計ジャッジ時間 4,129 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 11 ms
4,380 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 20 ms
4,384 KB
testcase_06 AC 101 ms
8,332 KB
testcase_07 AC 100 ms
8,412 KB
testcase_08 RE -
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 165 ms
8,408 KB
testcase_11 AC 164 ms
7,688 KB
testcase_12 AC 157 ms
8,872 KB
testcase_13 AC 136 ms
7,348 KB
testcase_14 AC 159 ms
8,064 KB
testcase_15 RE -
testcase_16 AC 2 ms
4,380 KB
testcase_17 RE -
testcase_18 RE -
testcase_19 AC 1 ms
4,384 KB
testcase_20 AC 1 ms
4,384 KB
testcase_21 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

void calc(int const sum, vector<int> const a, int const K, vector<int> &com){
    vector<int> na(a);
    if(na.empty()) return;
    if(sum+na.back()>K) return;
    int tmp=na.back();
    na.pop_back();
    com.push_back(sum+tmp);;
    calc(sum, na, K, com);
    calc(sum+tmp, na, K, com);
}

int main(){
    int N,K,in;
    vector<int> a, com;

    cin >> N >> K;
    while(cin >> in) a.push_back(in);
    sort(a.begin(),a.end(),greater<int>());
    calc(0,a,K,com);
    sort(com.begin(),com.end());
    cout << com.back() << endl;

    return 0;
}
0