I recently solved 743-D. This required me to create an adjacency list of size 2e5. So, I'd to create a vector
of vector
s, i.e vector<vector<int>>
. If one checks the size of a vector<int>
variable, then we'll get 24
bytes. So, $$$4.8 \times 10^6$$$ bytes = 4.8MB. The question clearly mentions that we're given a total of 256 MBs. So the problem here might be that the stack size is smaller than 4.8 MB.
- So, What is the stack size, and the heap size?
My solution, that used this approach got an MLE (memory limit exceeded).
So, I decided to use the heap memory instead, (by using the new
keyword). Here is the submission. The code is obviously harder and less clear. So,
Are there other ways to avoid heap usage? Is there something obvious that I'm missing?
Are there some easier and obvious ways to use the heap memory?
Any help regarding this is appreciated!