結果

問題 No.15 カタログショッピング
ユーザー 👑 hos.lyrichos.lyric
提出日時 2015-01-30 10:21:18
言語 Ruby
(3.3.0)
結果
AC  
実行時間 760 ms / 5,000 ms
コード長 292 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 11,640 KB
実行使用メモリ 28,492 KB
最終ジャッジ日時 2023-08-26 23:13:07
合計ジャッジ時間 5,266 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,144 KB
testcase_01 AC 82 ms
15,176 KB
testcase_02 AC 81 ms
15,304 KB
testcase_03 AC 87 ms
15,172 KB
testcase_04 AC 80 ms
15,172 KB
testcase_05 AC 754 ms
28,396 KB
testcase_06 AC 748 ms
28,404 KB
testcase_07 AC 745 ms
28,332 KB
testcase_08 AC 760 ms
28,492 KB
testcase_09 AC 753 ms
28,384 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n,s=gets.split.map &:to_i
a=(0..n).map{gets.to_i}
h={}
(0...1<<n-n/2).each{|y|(h[(0..n).map{|i|(y>>i-n/2&1)*a[i]}.inject:+]||=[])<<y}
(0...1<<n/2).map{|x|(h[s-(0..n).map{|i|(x>>i&1)*a[i]}.inject(:+)]||[]).map{|y|x|y<<n/2}}.flatten.map{|z|(0..n).select{|i|z>>i-1&1>0}}.sort.each{|_|puts _*' '}
0