結果

問題 No.279 木の数え上げ
ユーザー ichibanshiboriichibanshibori
提出日時 2016-12-12 04:53:38
言語 OCaml
(5.1.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 582 bytes
コンパイル時間 234 ms
コンパイル使用メモリ 19,696 KB
実行使用メモリ 30,984 KB
最終ジャッジ日時 2024-04-17 08:35:37
合計ジャッジ時間 1,641 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 73 ms
27,844 KB
testcase_11 AC 14 ms
8,704 KB
testcase_12 AC 51 ms
20,900 KB
testcase_13 AC 7 ms
6,528 KB
testcase_14 AC 80 ms
30,984 KB
testcase_15 AC 67 ms
26,976 KB
testcase_16 AC 59 ms
24,080 KB
testcase_17 AC 67 ms
27,848 KB
testcase_18 AC 35 ms
16,396 KB
testcase_19 AC 72 ms
29,104 KB
testcase_20 AC 78 ms
29,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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