結果

問題 No.1628 Sorting Integers (MAX of M)
コンテスト
ユーザー tanson
提出日時 2026-02-01 00:45:51
言語 Standard ML
(MLton 20210117)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 995 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,614 ms
コンパイル使用メモリ 708,616 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2026-02-01 00:45:58
合計ジャッジ時間 5,591 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 6
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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 readInt () =
    valOf (TextIO.scanStream (Int.scan StringCvt.DEC) TextIO.stdIn)


val () =
    let
        val _ = readInt ()
        val digits_list =
            List.tabulate (9, fn i =>
                                 let
                                     val c = readInt ()
                                 in
                                     List.tabulate (c, fn _ => i + 1)
                                 end)
        val digits = List.concat digits_list
        val sorted_digits = List.rev (quicksort digits)
        val ans = String.concat (List.map (fn d => Int.toString d) sorted_digits)
    in
        print (ans ^ "\n")
    end
0