Codeforces and Polygon may be unavailable from December 6, 19:00 (UTC) to December 6, 21:00 (UTC) due to technical maintenance. ×

brdy's blog

By brdy, history, 7 years ago, In English

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?

  • Vote: I like it
  • +9
  • Vote: I do not like it

»
7 years ago, # |
  Vote: I like it +5 Vote: I do not like it

How do you know there are only one int and one pointer on one stack frame? Read this https://softwareengineering.stackexchange.com/questions/195385/understanding-stack-frame-of-function-call-in-c-c

  • »
    »
    7 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Thanks, I was suspecting there was more.