• + 0 comments

    haskell

    import Data.List (intercalate)
    import Data.Array (accumArray, elems)
    
    counts l u xs = accumArray (+) 0 (l, u) [(x, 1) | x <- xs]
    
    missing l u xs ys =
      let cx = elems $ counts l u xs
          cy = elems $ counts l u ys
        in [i | (i, a, b) <- zip3 [l..] cx cy, a < b]
    
    main = do
      getLine
      lx <- getLine
      getLine
      ly <- getLine
      let xs = map read $ words lx :: [Int]
          ys = map read $ words ly :: [Int]
          l = min (minimum xs) (minimum ys)
          u = max (maximum xs) (maximum ys)
      putStrLn $ intercalate " " $ map show $ missing l u xs ys