結果

問題 No.45 回転寿司
ユーザー kashiwagi513
提出日時 2019-03-01 14:39:20
言語 OCaml
(5.5.0)
コンパイル:
ocamlfind ocamlopt -linkpkg -package zarith,str _filename_ -o a.out
実行:
./a.out
結果
MLE  
実行時間 -
コード長 532 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 106 ms
コンパイル使用メモリ 21,504 KB
実行使用メモリ 1,306,752 KB
最終ジャッジ日時 2026-09-12 07:24:14
合計ジャッジ時間 7,680 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 4
other MLE * 2 -- * 28
権限があれば一括ダウンロードができます
コンパイルメッセージ
ocamlfind: [WARNING] Cannot read directory ./stublibs which is mentioned in ld.conf

ソースコード

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