結果

問題 No.37 遊園地のアトラクション
ユーザー らっしー(raccy)らっしー(raccy)
提出日時 2015-06-15 23:19:18
言語 Ruby
(3.3.0)
結果
RE  
実行時間 -
コード長 688 bytes
コンパイル時間 210 ms
コンパイル使用メモリ 11,312 KB
実行使用メモリ 15,564 KB
最終ジャッジ日時 2023-09-21 02:24:25
合計ジャッジ時間 4,407 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:2: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

t = gets.to_i
n = gets.to_i
$c_list = gets.split.map(&:to_i)
$v_list = gets.split.map(&:to_i)

$max_manzoku = 0

def manzoku(kore)
  man = 0
  kore.each_with_index do |count, i|
    m = $v_list[i]
    count.times do
      man += m
      m /= 2
    end
  end
  return man
end

def noru_ato(nokori, ima, kore)
  if ima == n - 1
    kore << nokori / $c_list[ima]
    $max_manzoku = [manzoku(kore), $max_manzoku].max
  else
    count = 0
    loop do
      next_nokori = nokori - count * $c_list[ima]
      if next_nokori <= 0
        noru_ato(next_nokori, ima + 1, kore + [count])
        count += 1
      else
        break
      end
    end
  end
end

noru_ato(t, 0, [])

puts $max_manzoku
0