結果

問題 No.10 +か×か
ユーザー gigurururugigurururu
提出日時 2014-11-27 14:23:46
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,598 ms / 5,000 ms
コード長 277 bytes
コンパイル時間 197 ms
コンパイル使用メモリ 11,308 KB
実行使用メモリ 95,620 KB
最終ジャッジ日時 2023-08-21 06:09:18
合計ジャッジ時間 5,286 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
15,108 KB
testcase_01 AC 78 ms
15,148 KB
testcase_02 AC 77 ms
15,288 KB
testcase_03 AC 1,024 ms
78,316 KB
testcase_04 AC 98 ms
16,200 KB
testcase_05 AC 80 ms
15,148 KB
testcase_06 AC 1,598 ms
95,620 KB
testcase_07 AC 712 ms
48,640 KB
testcase_08 AC 141 ms
18,732 KB
testcase_09 AC 181 ms
22,848 KB
testcase_10 AC 80 ms
15,168 KB
testcase_11 AC 81 ms
15,344 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

gets
$t=gets.to_i
s,*$a=gets.split.map(&:to_i)

$memo={}
def dfs i,n
  return if $memo[[i,n]]
  $memo[[i,n]]=true
  return n==$t&&[] if !$a[i]
  return if n>$t
  if r=dfs(i+1,n+$a[i])
    [?+]+r
  elsif r=dfs(i+1,n*$a[i])
    [?*]+r
  end
end

puts dfs(0,s)*""
0