C++ Stack Limit in Codeforces

Revision en1, by brdy, 2018-01-05 00:30:53

According to a comment by ffao, Codeforces reserves 256MB to stack size by default.

However, my solution that does not exceed 1e7 layers of recursion in this sample 33910932, yet it RTE's because of too deep recursion. (I had to write iterative solution to get AC)

Supposing each 64 bit int uses 8 bytes, and a pointer in a 64-bit compiler would take 8 bytes. 1e7 * 16 bytes = 160 megabytes.

Is there extra memory usage I am unaware about? Shouldn't this be able to squeeze under the size limit?

Tags #stack, #memory, #limit, #codeforces


  Rev. Lang. By When Δ Comment
en1 English brdy 2018-01-05 00:30:53 629 Initial revision (published)