Jim_Moriarty_'s blog

By Jim_Moriarty_, history, 5 years ago, In English

I was recently solving a problem using a vector first but I got MLE (memory limit exceeded). Then I declared an array of maximum size it got accepted in only 64 KiB. So if any of you know about how does memory limit get affected when we declare anything (large size) globally. And how does it affect the memory limit.

Code which got MLE — https://www.hackerearth.com/submission/41144649/ Code which got AC — https://www.hackerearth.com/submission/41145515/

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

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

If you provide your code it would be better for explaining.

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

Auto comment: topic has been updated by Jim_Moriarty_ (previous revision, new revision, compare).

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

The only problem is that in your MLE solution you have used struct of type long long while in your accepted solution the array is of type int (The memory is obviously reduced by half in this case).
- I don't know how Memory verdict of Hackerearth works but your array da[5000000][26] took 508804 KB on Codeforces custom test, while on Hackerearth it shows only 64KiB. So i suggest you not to rely on Hackerearth Memory Verdict (idk how it works).

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +4 Vote: I do not like it

    Yeah! I thought same that something is wrong with the memory limit , because I was obviously using more than 64KiB.