fork(1) download
  1. f n k xs = ws where
  2. ws = zipWith3 (\x y z -> x + y + z) xs ys zs
  3. ys = last xs : init xs
  4. zs = last ys : init ys
  5.  
  6.  
  7. main = do
  8. [n, k] <- getLine >>= (return . map read . words) :: IO [Int]
  9. xs <- getLine >>= (return . map read . words) :: IO [Int]
  10. print $ f n k xs
  11.  
Success #stdin #stdout 0s 6288KB
stdin
9 3
1 1 1 1 0 0 0 1 1
stdout
[3,3,3,3,2,1,0,1,2]