Created
December 4, 2014 16:24
-
-
Save lauzi/f94b5db8f5cbed8f0fd6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 1 | |
main = interact $ show . sum . map read . tail . lines | |
-- 2 | |
f [a, b, c] = if a <= b then 0 else (a-b)*c | |
main = interact $ show . sum . map (f . map read . words) . tail . lines | |
-- 3 | |
import Control.DeepSeq | |
f (t : _ : xs) = psums `deepseq` maximum diffs | |
where psums = scanl (+) 0 xs | |
diffs = zipWith (-) (drop t psums) psums | |
main = interact $ show . f . map read . words |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment