結果
問題 | No.617 Nafmo、買い出しに行く |
ユーザー | ikd |
提出日時 | 2017-12-17 00:05:07 |
言語 | D (dmd 2.106.1) |
結果 |
AC
|
実行時間 | 59 ms / 2,000 ms |
コード長 | 579 bytes |
コンパイル時間 | 1,455 ms |
コンパイル使用メモリ | 84,176 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-09-03 17:40:45 |
合計ジャッジ時間 | 2,650 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 4 ms
4,380 KB |
testcase_04 | AC | 1 ms
4,380 KB |
testcase_05 | AC | 8 ms
4,376 KB |
testcase_06 | AC | 58 ms
4,376 KB |
testcase_07 | AC | 56 ms
4,376 KB |
testcase_08 | AC | 1 ms
4,380 KB |
testcase_09 | AC | 1 ms
4,376 KB |
testcase_10 | AC | 57 ms
4,380 KB |
testcase_11 | AC | 57 ms
4,380 KB |
testcase_12 | AC | 58 ms
4,376 KB |
testcase_13 | AC | 57 ms
4,376 KB |
testcase_14 | AC | 58 ms
4,376 KB |
testcase_15 | AC | 59 ms
4,380 KB |
testcase_16 | AC | 57 ms
4,376 KB |
testcase_17 | AC | 57 ms
4,384 KB |
testcase_18 | AC | 1 ms
4,380 KB |
testcase_19 | AC | 1 ms
4,380 KB |
testcase_20 | AC | 1 ms
4,380 KB |
testcase_21 | AC | 1 ms
4,376 KB |
ソースコード
void main(){ import std.stdio, std.string, std.conv, std.algorithm; int n, wmax; rd(n, wmax); auto w=new int[](n); foreach(i; 0..n) rd(w[i]); int mx=0; foreach(bit; 0..(1<<n)){ int s=0; foreach(i; 0..n)if(bit&(1<<i)) s+=w[i]; if(s<=wmax) mx=max(mx, s); } writeln(mx); } void rd(T...)(ref T x){ import std.stdio, std.string, std.conv; auto l=readln.split; assert(l.length==x.length); foreach(i, ref e; x){ e=l[i].to!(typeof(e)); } } void wr(T...)(T x){ import std.stdio; foreach(e; x) stderr.write(e, " "); stderr.writeln(); }