結果

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

ソースコード

diff #
raw source code

let list_of_string str =
  let lstr = String.length str in
  let rec list_of_string' idx result =
    if idx >= lstr then result
    else list_of_string' (idx + 1) (str.[idx] :: result)
  in
  list_of_string' 0 []


let solve s =
  let c_lst = list_of_string s in
  let t_cnt = List.filter (fun c -> c = 't') c_lst |> List.length
  and r_cnt = List.filter (fun c -> c = 'r') c_lst |> List.length
  and e_cnt = List.filter (fun c -> c = 'e') c_lst |> List.length
  in
  min t_cnt (min r_cnt (e_cnt / 2))

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