結果

問題 No.182 新規性の虜
コンテスト
ユーザー tanson
提出日時 2026-05-06 01:24:01
言語 Standard ML
(MLton 20241230)
コンパイル:
mlton_wrapper _filename_
実行:
./main
結果
TLE  
実行時間 -
コード長 1,049 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,124 ms
コンパイル使用メモリ 705,036 KB
実行使用メモリ 51,740 KB
最終ジャッジ日時 2026-05-06 01:24:41
合計ジャッジ時間 10,548 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 TLE * 1 -- * 5
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

fun readInt () =
    valOf (TextIO.scanStream (Int.scan StringCvt.DEC) TextIO.stdIn)

fun readLargeInt () =
    valOf (TextIO.scanStream (LargeInt.scan StringCvt.DEC) TextIO.stdIn)

fun quicksort [] = []
  | quicksort (h::tl) =
    let 
        val (s, b) =
            List.foldl
                (fn (x, (small, big)) =>
                    if x <= h then (x::small, big)
                    else (small, x::big))
                ([], [])
                tl
    in
        (quicksort s) @ [h] @ (quicksort b)
    end

fun findAns [] (_, true) = 1
  | findAns [] (_, false) = 0 
  | findAns (h :: tl) (old, true) =
    if h = old then findAns tl (old, false)
    else 1 + findAns tl (h, true)
  | findAns (h :: tl) (old, false) = 
    if h = old then findAns tl (old, false)
    else findAns tl (h, true)


val () =
    let
        val n = readInt ()
        val a_s = List.tabulate (n, fn _ => readLargeInt ())

        val sorted = quicksort a_s

        val ans = findAns sorted (~1, false)
    in
        print (Int.toString ans ^ "\n")
    end
0