• + 0 comments

    Haskell

    module Main where
    
    import qualified Data.Map as M
    
    missingNumbers :: [Int] -> [Int] -> [Int]
    missingNumbers xs ys = do
        let mx = M.fromListWith (+) $ zip xs $ repeat 1
        let my = M.fromListWith (+) $ zip ys $ repeat 1
        let diff = M.differenceWith (\y x -> if x == y then Nothing else Just (y - x)) my mx
        M.keys diff
    
    main :: IO ()
    main = do
        _ <- getLine
        xs <- fmap (map read . words) getLine
        _ <- getLine
        ys <- fmap (map read . words) getLine
        let result = missingNumbers xs ys
        putStrLn $ unwords $ map show result