結果
問題 |
No.37 遊園地のアトラクション
|
ユーザー |
|
提出日時 | 2015-06-15 23:18:53 |
言語 | Ruby (3.4.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 706 bytes |
コンパイル時間 | 535 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 12,544 KB |
最終ジャッジ日時 | 2024-07-06 21:06:01 |
合計ジャッジ時間 | 3,346 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 4 |
other | RE * 27 |
コンパイルメッセージ
Main.rb:4: warning: assigned but unused variable - n Syntax OK
ソースコード
# TLE! TLE! TLE! 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