結果

問題 No.617 Nafmo、買い出しに行く
ユーザー kokatsukokatsu
提出日時 2022-04-25 22:52:43
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 371 bytes
コンパイル時間 1,826 ms
コンパイル使用メモリ 199,984 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-04 16:51:21
合計ジャッジ時間 4,210 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
4,380 KB
testcase_01 AC 7 ms
4,380 KB
testcase_02 AC 68 ms
4,380 KB
testcase_03 AC 79 ms
4,380 KB
testcase_04 AC 12 ms
4,376 KB
testcase_05 AC 82 ms
4,376 KB
testcase_06 AC 89 ms
4,380 KB
testcase_07 AC 89 ms
4,376 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 6 ms
4,376 KB
testcase_10 AC 89 ms
4,376 KB
testcase_11 AC 89 ms
4,376 KB
testcase_12 AC 90 ms
4,376 KB
testcase_13 AC 90 ms
4,380 KB
testcase_14 AC 90 ms
4,380 KB
testcase_15 AC 89 ms
4,380 KB
testcase_16 AC 88 ms
4,376 KB
testcase_17 AC 89 ms
4,376 KB
testcase_18 AC 4 ms
4,376 KB
testcase_19 AC 5 ms
4,380 KB
testcase_20 AC 6 ms
4,380 KB
testcase_21 AC 9 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main() {
    int N, K;
    readf("%d %d\n", N, K);

    auto A = new int[](N);
    foreach (i; 0 .. N) readf("%d\n", A[i]);

    int res, L = 1 << 20;
    foreach (i; 0 .. L) {
        int weight;
        foreach (j, a; A) {
            if ((i >> j) & 1) weight += a;
        }

        if (weight <= K) res = max(res, weight);
    }

    res.writeln;
}
0