Блог пользователя Svapnil007

Автор Svapnil007, история, 3 года назад, По-английски

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.com/contest/1467/submission/103815290

  • Проголосовать: нравится
  • -3
  • Проголосовать: не нравится

»
3 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

»
3 года назад, # |
  Проголосовать: нравится +12 Проголосовать: не нравится

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