Created
December 22, 2015 06:45
-
-
Save autotaker/082402e29104b2f21a6d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import qualified Data.ByteString.Char8 as B | |
import Data.Maybe | |
import Control.DeepSeq | |
import Data.Time | |
import Control.Exception(evaluate) | |
import System.IO | |
import Text.Printf | |
import Prelude hiding(log) | |
import Data.List(sort) | |
log :: String -> IO UTCTime | |
log xs = do | |
t <- getCurrentTime | |
hPrintf stderr "[%s] %s\n" (show t) xs | |
return t | |
main :: IO () | |
main = do | |
t0 <- log "begin" | |
xs <- map (fst . fromJust . B.readInt) . B.words <$> B.getContents | |
evaluate (rnf xs) | |
t1 <- log "parse done" | |
let ls = sort xs | |
evaluate (rnf ls) | |
t2 <- log "sort done" | |
let dt = diffUTCTime t2 t1 | |
_ <- log $ printf "Sorting: %s" (show dt) | |
putStr $ unlines $ map show ls | |
t3 <- log "output done" | |
_ <- log $ printf "Elapsed Time: %s" (show (diffUTCTime t3 t0)) | |
return () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment