AtCoder Beginner Contest 009

Submission #3974130

Source codeソースコード

structure I  = Int
structure L  = List
structure SC = StringCvt
structure T  = TextIO

fun nextInt () = valOf (T.scanStream (I.scan SC.DEC) T.stdIn)

fun unique []           = []
  | unique [x]          = [x]
  | unique (x1::x2::xs) = if x1 = x2 then unique (x2::xs) else x1::unique (x2::xs)

local
  fun merge _ ([], ys)             = ys
    | merge _ (xs, [])             = xs
    | merge (op <=) (x::xs, y::ys) =
      if x <= y then x::merge (op <=) (xs, y::ys)
      else y::merge (op <=) (x::xs, ys)
  fun sort _ (0, xs)       = ([], xs)
    | sort _ (1, x::xs)    = ([x], xs)
    | sort (op <=) (n, xs) =
      let
        val (l1, xs1) = sort (op <=) ((n + 1) div 2, xs)
        val (l2, xs2) = sort (op <=) (n div 2, xs1)
      in
        (merge (op <=) (l1, l2), xs2)
      end
in
fun msort (op <=) xs =
    let
      val (l, _) = sort (op <=) (length xs, xs)
    in
      l
    end
end

val () =
    let
        val n = nextInt ()
        val x1::x2::xs = unique (msort (op >=)
                                       (L.tabulate (n, fn _ => nextInt ())))
    in
        print (I.toString x2 ^ "\n")
    end

Submission

Task問題 B - 心配性な富豪、ファミリーレストランに行く。
User nameユーザ名 masquerade0324
Created time投稿日時
Language言語 Standard ML (MLton 20100608)
Status状態 AC
Score得点 100
Source lengthソースコード長 1161 Byte
File nameファイル名
Exec time実行時間 1 ms
Memory usageメモリ使用量 384 KB

Compiler messageコンパイルメッセージ

Warning: Main.sml 39.14.
Declaration is not exhaustive.
missing pattern: (:: (_, nil)) | nil
in: x1 :: x2 :: xs = unique (msort (o ... ) => (nextInt ()))))

Test case

Set

Set name Score得点 / Max score Cases
All 100 / 100 random_1.txt,random_10.txt,random_2.txt,random_3.txt,random_4.txt,random_5.txt,random_6.txt,random_7.txt,random_8.txt,random_9.txt,sample_1.txt,sample_2.txt,sample_3.txt,small_1.txt,small_2.txt,small_3.txt,small_4.txt,small_5.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
random_1.txt AC 1 ms 256 KB
random_10.txt AC 1 ms 384 KB
random_2.txt AC 1 ms 256 KB
random_3.txt AC 1 ms 256 KB
random_4.txt AC 1 ms 256 KB
random_5.txt AC 1 ms 256 KB
random_6.txt AC 1 ms 256 KB
random_7.txt AC 1 ms 256 KB
random_8.txt AC 1 ms 256 KB
random_9.txt AC 1 ms 384 KB
sample_1.txt AC 1 ms 256 KB
sample_2.txt AC 1 ms 256 KB
sample_3.txt AC 1 ms 256 KB
small_1.txt AC 1 ms 256 KB
small_2.txt AC 1 ms 256 KB
small_3.txt AC 1 ms 256 KB
small_4.txt AC 1 ms 256 KB
small_5.txt AC 1 ms 256 KB