結果

問題 No.617 Nafmo、買い出しに行く
ユーザー uec20poke_Naauec20poke_Naa
提出日時 2023-03-15 19:11:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 475 ms / 2,000 ms
コード長 1,280 bytes
コンパイル時間 2,182 ms
コンパイル使用メモリ 208,544 KB
実行使用メモリ 14,376 KB
最終ジャッジ日時 2023-10-18 12:29:25
合計ジャッジ時間 6,068 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 20 ms
5,620 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 51 ms
8,548 KB
testcase_06 AC 103 ms
4,348 KB
testcase_07 AC 103 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 468 ms
14,376 KB
testcase_11 AC 467 ms
13,196 KB
testcase_12 AC 402 ms
11,032 KB
testcase_13 AC 344 ms
10,900 KB
testcase_14 AC 475 ms
13,348 KB
testcase_15 AC 87 ms
4,348 KB
testcase_16 AC 87 ms
4,348 KB
testcase_17 AC 87 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for(int i = (s); i < (int)(n); i++)
#define printYN(check) cout << ((check)? "Yes" : "No") << endl
#define NUM 998244353
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using tii = tuple<int, int, int>;
using Graph = vvi;
// Graph graph(n);
// vi dx = {-1, 0, 1, -1, 1, -1,  0, 1};
// vi dy = { 1, 1, 1,  0, 0, -1, -1,-1};
// snippet -> {UnionFind, dfs_reculsive, dfs_stack, is_prime, 
//              bfs_queue, digsum, binary_search, gcd, Dijkstra, bitsearch}
// --------------------------------------------------------------------------

int main() {
    int n, k;
    cin >> n >> k;
    vi arr(n);
    rep(i, n) {
        cin >> arr[i];
    }
    set<int> ans;
    rep(i, (1<<n)) {
        bitset<100> bits(i);
        int sum = 0;
        rep(j, n) {
            if(bits.test(j)) {
                sum += arr[j];
            }
        }
        if(sum <= k) {
            ans.insert(sum);
        }
    }
    cout << *ans.rbegin() << endl;
    return 0;
}
0