結果

問題 No.15 カタログショッピング
ユーザー 👑 hos.lyrichos.lyric
提出日時 2015-01-30 10:29:48
言語 Ruby
(3.3.0)
結果
AC  
実行時間 765 ms / 5,000 ms
コード長 279 bytes
コンパイル時間 203 ms
コンパイル使用メモリ 11,448 KB
実行使用メモリ 28,484 KB
最終ジャッジ日時 2023-08-27 05:27:07
合計ジャッジ時間 5,078 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,256 KB
testcase_01 AC 84 ms
15,100 KB
testcase_02 AC 84 ms
15,012 KB
testcase_03 AC 87 ms
15,068 KB
testcase_04 AC 84 ms
15,072 KB
testcase_05 AC 764 ms
28,480 KB
testcase_06 AC 762 ms
28,372 KB
testcase_07 AC 765 ms
28,376 KB
testcase_08 AC 759 ms
28,244 KB
testcase_09 AC 760 ms
28,484 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n,s=gets.split.map &:to_i
a=(0..n).map{gets.to_i}
h=(0...1<<n-n/2).group_by{|y|(0..n).map{|i|(y>>i-n/2&1)*a[i]}.inject:+}
puts (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.map{|_|_*' '}
0