Thanks Sumit, I changed my folds to a strict foldl'. I'll check how long it runs now.

Doug, I think you are absolutely correct. Taking the harmonic mean probably factored into the solution, in order to make it algorithmically feasible for the large input! Lesson learnt, next time I'll probably think harder about the problem than the code ;)

On Sat, Apr 18, 2015 at 7:29 AM, Doug McIlroy <doug@cs.dartmouth.edu> wrote:
> Can someone tell me how I could have avoided or fixed this?

The trouble manifested as stack overflow on solving

> https://code.google.com/codejam/contest/4224486/dashboard#s=p1

For efficiency, you'll probably need more cleverness in math than
in Haskell. You can predict an approximate start time for the Nth
customer's service from the average per-customer service time M,
where 1/M = sum 1/M_k.
Starting from that estimate, one can skip over almost the entire
service simulation.

Doug McIlroy