Task: | Inversions |
Sender: | Puhi~ |
Submission time: | 2018-05-26 11:40:46 +0300 |
Language: | Haskell |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.26 s | details |
#2 | ACCEPTED | 0.27 s | details |
#3 | ACCEPTED | 0.28 s | details |
#4 | ACCEPTED | 0.29 s | details |
#5 | ACCEPTED | 0.31 s | details |
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
Test details
Test 1
Verdict: ACCEPTED
input |
---|
000000000000000000000000000000... |
correct output |
---|
500000 |
user output |
---|
500000 |
Test 2
Verdict: ACCEPTED
input |
---|
111111111111111111111111111111... |
correct output |
---|
500000 |
user output |
---|
500000 |
Test 3
Verdict: ACCEPTED
input |
---|
010101010101010101010101010101... |
correct output |
---|
0 |
user output |
---|
0 |
Test 4
Verdict: ACCEPTED
input |
---|
101010101010101010101010101010... |
correct output |
---|
0 |
user output |
---|
0 |
Test 5
Verdict: ACCEPTED
input |
---|
110101011010110100100111110110... |
correct output |
---|
499476 |
user output |
---|
499476 |