結果
問題 |
No.617 Nafmo、買い出しに行く
|
ユーザー |
|
提出日時 | 2018-01-10 13:52:17 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 109 ms / 2,000 ms |
コード長 | 505 bytes |
コンパイル時間 | 685 ms |
コンパイル使用メモリ | 101,632 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-12 23:28:18 |
合計ジャッジ時間 | 2,485 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
import std.algorithm, std.conv, std.range, std.stdio, std.string; import std.bitmanip; // BitArray void main() { int n, k; read2(n, k); auto a = readArrayM!int(n); auto ans = 0; foreach (i; 0..1<<n) { auto s = a.indexed(i.bitsSet).sum; if (s <= k) ans = max(ans, s); } writeln(ans); } void read2(S,T)(ref S a,ref T b){auto r=readln.splitter;a=r.front.to!S;r.popFront;b=r.front.to!T;} T[] readArrayM(T)(size_t n){auto a=new T[](n);foreach(ref ai; a)ai=readln.chomp.to!T;return a;}