Submission #2757098


Source Code Expand

let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.to_list @@ Array.init n @@ fun _ ->
    Scanf.scanf "%d\n" @@ fun a -> a in
  let bs = Array.to_list @@ Array.init n @@ fun _ ->
    Scanf.scanf "%d\n" @@ fun b -> b in
  List.map (fun a -> (true, a)) as_ @ List.map (fun b -> (false, b)) bs
  |> List.sort (fun (_, a) (_, b) -> compare a b)
  |> List.map fst
  |> List.fold_left (fun (acc, s) b ->
      match s with
      | None -> (acc, Some (b, 1))
      | Some (b', n) ->
          if b = b' then (acc, Some (b', n + 1))
          else (acc * n mod 1000000007, if n = 1 then None else Some (b', n - 1))) (1, None)
  |> fst
  |> Printf.printf "%d\n"

Submission Info

Submission Time
Task A - 1D Matching
User fetburner
Language OCaml (4.02.3)
Score 500
Code Size 677 Byte
Status AC
Exec Time 223 ms
Memory 33796 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 2
AC × 14
Set Name Test Cases
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt AC 129 ms 18816 KB
001.txt AC 37 ms 8576 KB
002.txt AC 54 ms 11648 KB
003.txt AC 63 ms 12928 KB
004.txt AC 211 ms 27392 KB
005.txt AC 222 ms 33796 KB
006.txt AC 221 ms 33792 KB
007.txt AC 222 ms 33792 KB
008.txt AC 222 ms 33792 KB
009.txt AC 223 ms 33792 KB
010.txt AC 218 ms 33792 KB
011.txt AC 219 ms 33792 KB
example0.txt AC 1 ms 384 KB
example1.txt AC 1 ms 384 KB