結果

問題 No.45 回転寿司
ユーザー kashiwagi513
提出日時 2019-03-01 14:39:20
言語 OCaml
(5.4.1)
コンパイル:
ocamlfind ocamlopt -linkpkg -package zarith,str _filename_ -o a.out
実行:
./a.out
結果
MLE  
実行時間 -
コード長 532 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 187 ms
コンパイル使用メモリ 21,180 KB
実行使用メモリ 1,319,552 KB
最終ジャッジ日時 2026-04-25 04:38:43
合計ジャッジ時間 12,419 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 4
other MLE * 2 -- * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

let rec range a b = if a >= b then [] else a::(range (a+1) b)

let rec solve acc count ls =
  match ls with
  | [] -> count::acc
  | n1::[] -> (count + n1)::acc
  | n1::n2::ns ->
     let acc' = solve acc (n1 + count) ns in
     solve acc' (n2 + count) (if List.length ns > 0 then List.tl ns else [])

let _ =
  let _ = int_of_string @@ read_line() in
  let inputs = String.split_on_char ' ' (read_line ()) in
  solve [] 0 (List.map (fun i -> int_of_string i) inputs)
  |> List.fold_left (fun acc v -> max acc v) (-1)
  |> print_int
0