Svapnil007's blog

By Svapnil007, history, 4 years ago, In English

When I uncomment 3rd line i.e when I convert all integer to long long. Why am I getting runtime error on test case 8. Without this conversion i.e. int to long long code is getting accepted.

https://codeforces.net/contest/1467/submission/103815290

  • Vote: I like it
  • -3
  • Vote: I do not like it

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Try initializing arr, down and up globally. It's generally not good to initialize arrays inside functions because of potential memory overflow

»
4 years ago, # |
  Vote: I like it +12 Vote: I do not like it

I faced similar issue and the reason is because of memory allocation in cpp. The arrays inside main are allocated on stack which has a fixed size of 256mb and when it exceeds that, it throws a runtime error. I didn't convert long long to int but instead used vectors (allocated on heap) and got ac