結果

問題 No.279 木の数え上げ
コンテスト
ユーザー korogy
提出日時 2017-09-12 01:48:31
言語 Ruby
(4.0.2)
コンパイル:
ruby -w -c _filename_
実行:
ruby _filename_
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 509 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 234 ms
コンパイル使用メモリ 9,088 KB
実行使用メモリ 16,640 KB
最終ジャッジ日時 2026-05-07 23:32:41
合計ジャッジ時間 2,984 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #
raw source code

class CountUpTrees
    attr_reader :s

    def initialize(s: "")
        @s = s
    end

    def cause
        begin
            @s = gets.chomp
        rescue
            
        end
    end

    def countuptrees(target)
        str = "tree".split("").uniq
        cnt = str.each.map { |c| target.count(c) }
        cnt[2] /= 2
        cnt.min
    end

    def result
        puts countuptrees(@s)
    end

    def run
        cause
        result
    end
end

if $0 == __FILE__
    CountUpTrees.new.run
end
0