結果

問題 No.617 Nafmo、買い出しに行く
ユーザー troro_kelptroro_kelp
提出日時 2018-09-04 00:32:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 1,201 bytes
コンパイル時間 1,041 ms
コンパイル使用メモリ 97,276 KB
実行使用メモリ 8,448 KB
最終ジャッジ日時 2024-04-18 10:37:17
合計ジャッジ時間 2,112 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,196 KB
testcase_01 AC 3 ms
8,448 KB
testcase_02 AC 4 ms
8,172 KB
testcase_03 AC 3 ms
8,128 KB
testcase_04 AC 4 ms
8,192 KB
testcase_05 AC 4 ms
8,168 KB
testcase_06 AC 6 ms
8,136 KB
testcase_07 AC 6 ms
8,280 KB
testcase_08 AC 4 ms
8,176 KB
testcase_09 AC 3 ms
8,232 KB
testcase_10 AC 7 ms
8,332 KB
testcase_11 AC 7 ms
8,320 KB
testcase_12 AC 7 ms
8,268 KB
testcase_13 AC 7 ms
8,296 KB
testcase_14 AC 6 ms
8,156 KB
testcase_15 AC 7 ms
8,152 KB
testcase_16 AC 6 ms
8,320 KB
testcase_17 AC 8 ms
8,308 KB
testcase_18 AC 4 ms
8,156 KB
testcase_19 AC 3 ms
8,308 KB
testcase_20 AC 3 ms
8,192 KB
testcase_21 AC 4 ms
8,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
//typedef std::pair<std::string,double> P;


#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
const constexpr ll MOD = 1e9+7;
vector<pair<int, int> > vp;
 
struct Less {
    bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
        return x.first > y.first;
    }
};

ll GCD(ll a, ll b){
    if(b==0) return a;
    return GCD(b, a%b);
}


//グラフの隣接リスト
VI g[200010];
//頂点の入次数を管理
int h[100010];
int a[21];
int ans;
int N, K;

void dfs(int idx, int sum){
    if(idx==N) {
        if(sum<=K) ans = max(ans, sum);
        return ;
    }
    dfs(idx+1, sum+a[idx]);
    dfs(idx+1, sum);
    return;
}
int main(void) {
     cin >> N >> K;
    REP(i, N) cin >> a[i];
    
    int t=0;
    dfs(0, t);
    cout << ans << endl;
    return 0;
}
0