結果
問題 |
No.406 鴨等間隔の法則
|
ユーザー |
|
提出日時 | 2025-10-01 00:59:31 |
言語 | Standard ML (MLton 20210117) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,199 bytes |
コンパイル時間 | 6,868 ms |
コンパイル使用メモリ | 691,704 KB |
実行使用メモリ | 21,512 KB |
最終ジャッジ日時 | 2025-10-01 00:59:42 |
合計ジャッジ時間 | 5,611 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 RE * 1 |
ソースコード
fun readInt () = valOf (TextIO.scanStream (Int.scan StringCvt.DEC) TextIO.stdIn) fun isSatisfy n l min diff = let val checkList = Array.array (n, false) fun check nil = true | check (h::tl) = let val index = (h - min) div diff in if Array.sub (checkList, index) = false then ( ( Array.update (checkList, index, true); check tl ) ) else false end in if diff = 0 then false else check l end val () = let val n = readInt () val x_s = List.tabulate (n, fn _ => readInt ()) val (min, max) = List.foldl (fn (x, (minAcc, maxAcc)) => (Int.min (x, minAcc), Int.max (x, maxAcc))) (100000000, 0) x_s val d = (max - min) div (n - 1) val ans = if isSatisfy n x_s min d then "YES" else "NO" in print (ans ^ "\n") end