結果
問題 |
No.135 とりあえず1次元の問題
|
ユーザー |
|
提出日時 | 2025-08-29 00:12:49 |
言語 | Standard ML (MLton 20210117) |
結果 |
TLE
|
実行時間 | - |
コード長 | 989 bytes |
コンパイル時間 | 6,952 ms |
コンパイル使用メモリ | 687,096 KB |
実行使用メモリ | 74,672 KB |
最終ジャッジ日時 | 2025-08-29 00:13:09 |
合計ジャッジ時間 | 17,503 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 2 |
other | TLE * 1 -- * 21 |
ソースコード
fun readInt () = valOf (TextIO.scanStream (Int.scan StringCvt.DEC) TextIO.stdIn) fun insertionSortNoDuplicate l = let fun insert x [] = [x] | insert x (y::ys) = if x = y then y::ys else if x < y then x::y::ys else y::(insert x ys) in foldl (fn (x, acc) => insert x acc) [] l end fun findAns l = let fun findAnsLoop [] min = min | findAnsLoop [_] min = min | findAnsLoop (h1 :: h2 :: tl) min = if h2 - h1 < min then findAnsLoop (h2 :: tl) (h2 - h1) else findAnsLoop (h2 :: tl) min val limit = 9999999 val ans = findAnsLoop (insertionSortNoDuplicate l) limit in if ans = limit then 0 else ans end val () = let val n = readInt () val x_s = List.tabulate (n, fn _ => readInt ()) val ans = findAns x_s in print (Int.toString ans ^ "\n") end