結果

問題 No.617 Nafmo、買い出しに行く
ユーザー kokatsu
提出日時 2022-04-25 22:52:43
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 371 bytes
コンパイル時間 2,412 ms
コンパイル使用メモリ 204,096 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-22 14:59:19
合計ジャッジ時間 3,566 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

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