Skip to content

Instantly share code, notes, and snippets.

@fbrubacher
Created June 20, 2016 15:34
Show Gist options
  • Save fbrubacher/d0a55f6e5abbefe5ea16c271514b517e to your computer and use it in GitHub Desktop.
Save fbrubacher/d0a55f6e5abbefe5ea16c271514b517e to your computer and use it in GitHub Desktop.
import Control.Applicative
import Control.Monad
import Data.List
main = (enumFromTo 1 <$> readLn) >>= mapM_ (\caseno -> do
getLine
x <- map read . words <$> getLine
y <- map read . words <$> getLine
let answer = sum $ zipWith (*) (sort x) (reverse $ sort y)
putStrLn $ "Case #" ++ show caseno ++ ": " ++ show answer
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment