結果

問題 No.15 カタログショッピング
ユーザー gigurururugigurururu
提出日時 2014-12-16 17:24:23
言語 Ruby
(3.3.0)
結果
AC  
実行時間 290 ms / 5,000 ms
コード長 263 bytes
コンパイル時間 355 ms
コンパイル使用メモリ 11,140 KB
実行使用メモリ 36,056 KB
最終ジャッジ日時 2023-08-27 05:23:59
合計ジャッジ時間 2,825 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,264 KB
testcase_01 AC 82 ms
15,008 KB
testcase_02 AC 83 ms
14,968 KB
testcase_03 AC 84 ms
15,336 KB
testcase_04 AC 82 ms
15,204 KB
testcase_05 AC 279 ms
36,056 KB
testcase_06 AC 285 ms
35,296 KB
testcase_07 AC 290 ms
35,744 KB
testcase_08 AC 289 ms
35,860 KB
testcase_09 AC 284 ms
35,960 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n,s=gets.split.map &:to_i
def f n,ofs
  d={0=>[[]]}
  n.times{|i|c=gets.to_i;d.dup.map{|k,v|d[k+c]=(d[k+c]||[])+v.map{|j|j+[i+1+ofs]}}}
  d
end
d1=f n/2,0
d2=f (n+1)/2,n/2
puts d1.flat_map{|k,v|(t=d2[s-k])?v.product(t).map{|i,j|i+j}:[]}.sort.map{|i|i*" "}
0