How can I calculate memory of a program to avoid MLE? Thanks!
# | User | Rating |
---|---|---|
1 | tourist | 3748 |
2 | Benq | 3540 |
3 | Petr | 3470 |
4 | Radewoosh | 3355 |
5 | ecnerwala | 3347 |
6 | maroonrk | 3345 |
7 | jiangly | 3324 |
8 | scott_wu | 3313 |
9 | ainta | 3298 |
10 | boboniu | 3289 |
# | User | Contrib. |
---|---|---|
1 | 1-gon | 200 |
2 | Errichto | 196 |
3 | rng_58 | 194 |
4 | SecondThread | 186 |
4 | awoo | 186 |
6 | Um_nik | 182 |
7 | vovuh | 179 |
8 | Ashishgup | 176 |
9 | -is-this-fft- | 173 |
9 | maroonrk | 173 |
How can I calculate memory of a program to avoid MLE? Thanks!
Name |
---|
To get an estimate you can check your array usage and STL container usage.
For array it will be memory of primitive type * array size, say int $$$x[1000][1000]$$$ uses $$$4 bytes * 1000 *1000 = 4MB$$$
For STL containers it will be a constant factor for that container * memory of primitive type * size + some constant (ignore as the first term will dominate) A ref here
In fact CF standard memory limit are so loose and you don't need to care at most cases. And the memory usage shown may differ < 1600KB from actual. I think you can forget those things and solve some problems first.
PS: In C/C++ a boolean takes 1 byte. If you want a boolean array with tight memory limit, use a char array and store 4 boolean in one char or use C++ bitset library. I remember there is such a question in contest in few years ago.