I was solving https://mirror.codeforces.com/contest/1283/problem/D , and created this code https://mirror.codeforces.com/contest/1283/submission/118870482 for it, it gives correct outputs, but i'm getting this error- memory limit exceeded at test 5 i researched a bit online and found that removing push_back statements and defining size of vector should help. but when i tried to do that usin a 1 d array...i got a worse memory limit exceeded error.. at test 3 only.
If anyone has any idea whats wrong, kindly do let me know. thanks!