結果

問題 No.279 木の数え上げ
コンテスト
ユーザー ichibanshibori
提出日時 2016-12-12 05:05:45
言語 OCaml
(5.5.0)
コンパイル:
ocamlfind ocamlopt -linkpkg -package zarith,str _filename_ -o a.out
実行:
./a.out
結果
AC  
実行時間 6 ms / 2,000 ms
+ 336µs
コード長 564 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 109 ms
コンパイル使用メモリ 21,248 KB
実行使用メモリ 7,168 KB
最終ジャッジ日時 2026-09-12 07:08:48
合計ジャッジ時間 1,464 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
ocamlfind: [WARNING] Cannot read directory ./stublibs which is mentioned in ld.conf

ソースコード

diff #
raw source code

let solve s =
  let lstr = String.length s in

  let rec solve' idx result =
    if idx >= lstr then result
    else
      let t_cnt, r_cnt, e_cnt = result in
      let t_cnt, r_cnt, e_cnt =
        t_cnt + (if s.[idx] = 't' then 1 else 0),
        r_cnt + (if s.[idx] = 'r' then 1 else 0),
        e_cnt + (if s.[idx] = 'e' then 1 else 0)
      in
      solve' (idx + 1) (t_cnt, r_cnt, e_cnt)
  in
  let t_cnt, r_cnt, e_cnt = solve' 0 (0, 0, 0) in
  min t_cnt (min r_cnt (e_cnt / 2))

let () =
  let s = read_line () in
  solve s |> string_of_int |> print_endline
0