結果
| 問題 | No.617 Nafmo、買い出しに行く | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2018-01-13 09:51:12 | 
| 言語 | D (dmd 2.109.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 66 ms / 2,000 ms | 
| コード長 | 589 bytes | 
| コンパイル時間 | 757 ms | 
| コンパイル使用メモリ | 117,688 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-06-12 23:32:51 | 
| 合計ジャッジ時間 | 2,141 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 20 | 
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;
void main() {
    auto s = readln.split;
    auto N = s[0].to!int;
    auto K = s[1].to!int;
    auto A = N.iota.map!(_ => readln.chomp.to!int).array;
    int ans = 0;
    foreach (mask; 0..(1<<N)) {
        int cnt = 0;
        foreach (i; 0..N) {
            if (mask & (1 << i)) {
                cnt += A[i];
            }
        }
        if (cnt <= K) ans = max(ans, cnt);
    }
    ans.writeln;
}
            
            
            
        