Problem in executing program in sublime text

I was solving Google Kickstarter-codejam question, where we need to take input file and produce output file. For small input file my sublime text editor was producing correct output which got accepted, but when I was trying to execute long input file which consists of about 26000 lines of input, it produced pop-up window saying program.exe has stopped working. Why did it occur? Is something wrong in my code or
something wrong with editor or compiler? How can I avoid this?

Pls, provide the sufficient data, so that users can generate the same error.I think that’s the one way of solving your problem.

I couldn’t find any fault in my code which could possibly give Runtime error. Could you have a look on my code. This is my code for this question

I have provided my code and the question’s link below in the comment. Have a look.


The problem is that you are declaring a large array inside the function main() i.e. stack memory

1 <= R <= 3000, 1 <= C <= 3000

So, an array[R][C] of size as big as 9000000 elements should declared globally i.e. heap memory.

Your code works fine if you declare the arrays a[r][c] and dp[r+1][c+1] globally.

You can read about this in the following link.


Oh!! I didn’t think of that. Thanks !! It worked.