Memory limit exceeded although using much less

Revision en1, by SomethingIrrelevant, 2020-06-05 15:24:49

So, I'm trying to solve the Multiset problem (

The memory limit is:

but then I get a MLE although I'm only using 19MB (far from 28MB).

What's the rationale behind this?

My code only uses the following data:

        int n2 = 1048576;
        int[] actualArray = new int[2 * n2];

so it should be about (2 * 1048576) * 4 bytes ~= 8MB. So, again, I'm far from 19MB. Any ideas why I get MLE?

The idea of my algorithm ( is to use a segment tree. Where every leaf correspond to values from 1 to 10^6 (maximum n) and a leaf i contains how many times a value i exists in the initial array. Then, we sum up the leaves, etc.

Tags memory limit excceded


  Rev. Lang. By When Δ Comment
en1 English SomethingIrrelevant 2020-06-05 15:24:49 887 Initial revision (published)