結果
問題 | No.112 ややこしい鶴亀算 |
ユーザー |
![]() |
提出日時 | 2017-08-15 20:40:36 |
言語 | OCaml (5.2.1) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 461 bytes |
コンパイル時間 | 277 ms |
コンパイル使用メモリ | 21,736 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-09 00:18:51 |
合計ジャッジ時間 | 1,197 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 23 |
ソースコード
let read () = Scanf.scanf "%d " (fun i -> i) let () = let n = read () in let a = Array.init n (fun _ -> read ()) in let c = Array.fold_left (fun c e -> max c (2 * (n - 1) - e / 2)) 0 a in if c <> n - 1 then Printf.printf "%d %d\n" c (n - c) else let rec doit i = if i = n then true else if a.(i) <> a.(i-1) then false else doit (i + 1) in if doit 1 then Printf.printf "%d %d\n" n 0 else Printf.printf "%d %d\n" c (n - c)