結果

問題 No.406 鴨等間隔の法則
ユーザー r6eve
提出日時 2017-08-14 14:25:19
言語 OCaml
(5.2.1)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 499 bytes
コンパイル時間 440 ms
コンパイル使用メモリ 21,444 KB
実行使用メモリ 6,784 KB
最終ジャッジ日時 2024-10-09 00:15:37
合計ジャッジ時間 3,111 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

let () =
  let n = Scanf.scanf "%d " (fun i -> i) in
  let x = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  Array.fast_sort (-) x;
  let rec doit i =
    if i = n then true
    else if x.(i-1) = x.(i) then false
    else doit (i + 1) in
  if not (doit 1) then print_endline "NO"
  else
    let d = x.(1) - x.(0) in
    let rec doit i =
      if i = n then true
      else if x.(i) - x.(i-1) <> d then false
      else doit (i + 1) in
    print_endline (if doit 2 then "YES" else "NO")
0