Code Submission Evaluation System Login

CSES - HIIT Open 2018

HIIT Open 2018

Contest start:2018-05-26 11:00:00
Contest end:2018-05-26 16:00:00

Task list | Submit code | Submissions | Messages | Scoreboard | Statistics


History
2018-05-26 11:40:46
Task:Inversions
Sender:Puhi~
Submission time:2018-05-26 11:40:46
Status:READY
Result:ACCEPTED

Show test data

Compiler report

input/code.hs:1:1: warning: [-Wmissing-signatures]
    Top-level binding with no type signature: main :: IO ()

input/code.hs:10:1: warning: [-Wmissing-signatures]
    Top-level binding with no type signature:
      compar :: (Eq a1, Num a) => [a1] -> [a1] -> a

Code

main = do
    input <- getLine
    print $ solve input

solve :: String -> Integer
solve x = min (compar x a) (compar x b) where
    a = '0' : '1' : a
    b = '1' : a

compar a b =
    sum $ map (\x -> if x then 0 else 1)$ zipWith (==) a b