You are viewing a single comment's thread. Return to all comments →
Haskell
module Main where solve :: [Int] -> Maybe Int solve bs = go bs 0 where go [] acc = Just acc go [x] acc = if even x then Just acc else Nothing go (x : y : xs) acc | even x = go (y : xs) acc | otherwise = go (y + 1 : xs) (acc + 2) main :: IO () main = do n <- readLn :: IO Int bs <- map read . words <$> getLine :: IO [Int] case solve bs of Just acc -> print acc Nothing -> putStrLn "NO"
Seems like cookies are disabled on this browser, please enable them to open this website
Fair Rations
You are viewing a single comment's thread. Return to all comments →
Haskell