You are viewing a single comment's thread. Return to all comments →
Haskell
module Main where import Data.List.Split (chunksOf) solve :: Int -> [Int] -> Int solve k arr = length -- count the True . filter id -- only the Trues . zipWith elem [1 ..] -- is the page number in the page? $ concatMap (chunksOf k . flip take [1 ..]) arr -- list of pages' contents main :: IO () main = do [n, k] <- map read . words <$> getLine :: IO [Int] arr <- map read . words <$> getLine :: IO [Int] print $ solve k arr
Seems like cookies are disabled on this browser, please enable them to open this website
Lisa's Workbook
You are viewing a single comment's thread. Return to all comments →
Haskell