結果

問題 No.617 Nafmo、買い出しに行く
ユーザー kimiyukikimiyuki
提出日時 2017-12-19 20:35:56
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 401 bytes
コンパイル時間 7,077 ms
コンパイル使用メモリ 214,144 KB
実行使用メモリ 4,396 KB
最終ジャッジ日時 2023-08-22 06:59:56
合計ジャッジ時間 4,466 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 3 ms
4,384 KB
testcase_06 AC 3 ms
4,384 KB
testcase_07 AC 3 ms
4,384 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 2 ms
4,396 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 4 ms
4,384 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 3 ms
4,384 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 2 ms
4,384 KB
testcase_19 AC 2 ms
4,396 KB
testcase_20 AC 2 ms
4,384 KB
testcase_21 AC 2 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
using namespace std;

constexpr int max_k = 2e6;
int main() {
    int n, k; scanf("%d%d", &n, &k);
    assert (k <= max_k);
    bitset<max_k + 1> dp;
    dp[0] = true;
    while (n --) {
        int a_i; scanf("%d", &a_i);
        dp |= dp << a_i;
    }
    while (not dp[k]) k --;
    printf("%d\n", k);
    return 0;
}
0