結果

問題 No.617 Nafmo、買い出しに行く
コンテスト
ユーザー te-sh
提出日時 2017-12-18 17:01:24
言語 D
(dmd 2.112.0)
コンパイル:
dmd -fPIE -m64 -w -wi -O -release -inline -I/opt/dmd/src/druntime/import/ -I/opt/dmd/src/phobos -L-L/opt/dmd/linux/lib64/ -fPIC _filename_
実行:
./Main
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 386 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 518 ms
コンパイル使用メモリ 87,808 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2026-03-05 18:07:23
合計ジャッジ時間 2,315 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.bitmanip;  // BitArray

void main()
{
  auto rd = readln.split.to!(int[]), n = rd[0], k = rd[1];
  auto a = new int[](n);
  foreach (i; 0..n) a[i] = readln.chomp.to!int;

  auto ans = 0;
  foreach (i; 0..1<<n) {
    auto s = a.indexed(i.bitsSet).sum;
    if (s <= k) ans = max(ans, s);
  }

  writeln(ans);
}
0