The problem statement says that for test set 1, N is between 1 and 10^5. Your solution fails for values near the upper end of this range.
For example, given the input: > 1 > 44444 the output of your code is: > Case #1: -10546 -10546 -- You received this message because you are subscribed to the Google Groups "Google Code Jam" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/60a54ce1-a899-4c99-a2c7-9f64e3ca16dd%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
