Memory Limit exceeded while using vector but passed with global declared array

Revision en1, by harryb17, 2023-08-13 21:07:04

In a recent codeforces contest round 892 question E(Maximum Monogonosity) I received a strange MLE on my solution which uses a 3D vector, but the same solution passed when I used a global declared 3D array. I know global declared arrays are faster than vectors and take slightly less size cause of the vector dynamic nature of doubling memory while using push_back. But none of this happened in the following code. can anyone please explain why this happened?

Note: No I didn't use any constant memory of vector for every test case, such that for 1e5 test cases it would fail.

my 3D array was n*k*5, where n & k are <= 3000. the constraints are tight and even while using globally declared array, it was 300Mb out of 512Mb, so that might give a hint why it might fail for vectors, but still, I think there might be a better reason.

Link to my:

Accepted Solution round 892 problem E

Memory Limit Exceeded Solution round 892 problem E

Tags arrays, vectors, memory limit excceded, c++, array vs vector, #round892, #problem e

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English harryb17 2023-08-13 21:07:04 1148 Initial revision (published)