結果
| 問題 |
No.617 Nafmo、買い出しに行く
|
| コンテスト | |
| ユーザー |
ikd
|
| 提出日時 | 2017-12-17 00:05:07 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 66 ms / 2,000 ms |
| コード長 | 579 bytes |
| コンパイル時間 | 722 ms |
| コンパイル使用メモリ | 100,236 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-12 23:10:27 |
| 合計ジャッジ時間 | 2,381 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 |
ソースコード
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();
}
ikd