結果

問題 No.406 鴨等間隔の法則
ユーザー maimai8maimai8
提出日時 2020-07-25 21:33:54
言語 OCaml
(5.1.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 456 bytes
コンパイル時間 365 ms
コンパイル使用メモリ 21,576 KB
実行使用メモリ 7,552 KB
最終ジャッジ日時 2024-04-17 09:07:01
合計ジャッジ時間 2,157 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
6,400 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 49 ms
7,296 KB
testcase_05 AC 19 ms
6,144 KB
testcase_06 AC 20 ms
6,272 KB
testcase_07 AC 21 ms
6,144 KB
testcase_08 AC 49 ms
7,296 KB
testcase_09 AC 53 ms
7,552 KB
testcase_10 AC 23 ms
6,272 KB
testcase_11 AC 42 ms
7,040 KB
testcase_12 AC 28 ms
6,400 KB
testcase_13 AC 26 ms
6,528 KB
testcase_14 AC 45 ms
7,040 KB
testcase_15 AC 4 ms
5,376 KB
testcase_16 AC 6 ms
5,376 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 5 ms
5,376 KB
testcase_19 AC 7 ms
5,376 KB
testcase_20 AC 8 ms
5,504 KB
testcase_21 AC 8 ms
5,504 KB
testcase_22 AC 14 ms
5,888 KB
testcase_23 AC 29 ms
6,656 KB
testcase_24 AC 40 ms
7,040 KB
testcase_25 AC 54 ms
7,552 KB
testcase_26 AC 54 ms
7,552 KB
testcase_27 AC 41 ms
7,424 KB
testcase_28 AC 42 ms
7,552 KB
testcase_29 AC 54 ms
7,552 KB
testcase_30 AC 53 ms
7,424 KB
testcase_31 AC 52 ms
7,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

let () =
  Scanf.scanf "%d\n" @@ fun n ->
  let xrr = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun d -> d in
  let () = Array.fast_sort compare xrr in
  let diff = xrr.(1) - xrr.(0) in
  let arr = Array.sub xrr 1 (Array.length xrr - 1) in
  let ans = Array.fold_left 
      (fun (b, bfr) n -> if n - bfr = diff then (b && true, n) else (b && false, n))
      (true, xrr.(0)) arr in
  Printf.printf "%s\n" (if diff <> 0 && fst ans then "YES" else "NO")
0