Submission #3974130


Source Code Expand

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 Info

Submission Time
Task B - 心配性な富豪、ファミリーレストランに行く。
User masquerade0324
Language Standard ML (MLton 20100608)
Score 100
Code Size 1161 Byte
Status AC
Exec Time 1 ms
Memory 384 KB

Compile Error

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

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 18
Set Name Test Cases
All 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
Case Name Status Exec Time Memory
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