結果
| 問題 |
No.406 鴨等間隔の法則
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-10-01 01:01:23 |
| 言語 | Standard ML (MLton 20210117) |
| 結果 |
AC
|
| 実行時間 | 59 ms / 2,000 ms |
| コード長 | 1,274 bytes |
| コンパイル時間 | 2,966 ms |
| コンパイル使用メモリ | 691,704 KB |
| 実行使用メモリ | 21,504 KB |
| 最終ジャッジ日時 | 2025-10-01 01:01:29 |
| 合計ジャッジ時間 | 5,774 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
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 0 <= index andalso
index < n andalso
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