結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
kashiwagi513
|
| 提出日時 | 2019-03-01 21:22:04 |
| 言語 | OCaml (5.2.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 589 bytes |
| コンパイル時間 | 513 ms |
| コンパイル使用メモリ | 19,820 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-09 00:34:36 |
| 合計ジャッジ時間 | 1,368 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 1 WA * 29 |
ソースコード
let rec range a b = if a >= b then [] else a::(range (a+1) b)
let rec sum = function [] -> 0 | n::ns -> n + (sum ns)
let solve ls =
let rec inner ls prev cur must =
match ls with
| [] -> cur @ must
| x::xs ->
if cur == [] then inner xs prev [x] must
else if x > (List.hd cur) then inner xs cur (x::prev) must
else inner xs [] [] cur
in inner ls [] [] []
let _ =
let _ = int_of_string @@ read_line() in
let inputs = String.split_on_char ' ' (read_line ()) in
inputs
|> List.map (fun s -> int_of_string s)
|> solve
|> sum
|> print_int
kashiwagi513