Runtime Error in CHEFPRES

I am getting a runtime error (other) in CHEFPRES ( december challenge). The code works fine on my laptop as well as on ideone. Please explain meaning of runtime error (other) and why am I getting it

Maybe you can try C++ comppiler instead of C compiler. I cannot help you more, I’m blind without seeing source for such rare error, sorry.

I have seen this error once, it occurs when you are allocating too much global memory… like for example: declaring a global array of length more than 10^7. I can also say so, since the running time of your submission is 0.00 i.e. your program is stopping immediately. Try reducing the space complexity of your code. All the best :slight_smile:

1 Like

No. C++ compiler gives compilation error. Can you please tell me what are the most common reasons for getting runtime error (other)?

you may be using something like this :-

int a[100000001];

This line is the problem, its allocating too much memory in static allocation area!you could use malloc() to allocate this memory on the heap.

1 Like

I always thought it’s almost the same, but you may try what others said :wink:

I am using a global 2D array of 10001*10001 dimension. Will that cause the error? And as I said, The Code works fine on my laptop and IDEONE.

I am using a global 2D array of 10001*10001 dimension. Will that cause the error? And as I said, The Code works fine on my laptop and IDEONE.

yes it will give errors sometimes… you cannot create arrays of size 10^8… sometimes ideone and codechef may behave differently

For this problem old Pyramid servers are used, so there is very limited amount of memory…

Yes this is the reason, using too much memory

Thank You. I used malloc to allocate (n+1) * (n+1) int 2D array and although It worked for the first sub task, it gives SIGSEGV for the second. That means you can not allocate 10001 * 10001 array even with malloc?

No , you cannot allocate that much amount of memory :frowning:
SIGSEGV occurs when you are allocating too much memory or you are accessing array elements out of bound .