**Update:** [I got AC](https://codeforces.me/contest/1262/submission/65693790), i only changed the way of getting the elements to insert in the Treap, [this code help me](https://codeforces.me/contest/1262/submission/65651646). So the problem is not the treap, is the priority queue, but i'm still wanna kown why Memory Limit .-.↵
↵
Hi Codeforces, [5 month ago i asked for your help](https://codeforces.me/blog/entry/67838) and [user:meooow,2019-11-25] could solve my problem, thank you again for that :D.↵
↵
Sadly, i have a new problem that i can't solve by myself. ( I'm still trying to solve it )↵
↵
This time is with [D1](https://codeforces.me/contest/1262/problem/D1) and [D2](https://codeforces.me/contest/1262/problem/D2) problems from the last contest ( Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3 ).↵
↵
I made a solution that i think it should pass both D1 and D2 problems but i'm getting Memory limit exceeded on test 10.↵
↵
Here is my submission from D1 [code](https://codeforces.me/contest/1262/submission/65692467). The difference from D2 are the lines 89-91 because of the limits ( I only did this because i didn't know what else to do :( ).↵
↵
I think that my idea it's quite complicated to explain ( at least for me ), but i am working on it, maybe knowing what my code does someone would be able to help me..↵
↵
But, as i can see i only do $N$ insertions to the Treap and $N$ insertions to an auxiliary priority queue, i don´t have idea why i´m getting memory limit.↵
↵
I will appreciate any comment. Thank you :D
↵
Hi Codeforces, [5 month ago i asked for your help](https://codeforces.me/blog/entry/67838) and [user:meooow,2019-11-25] could solve my problem, thank you again for that :D.↵
↵
Sadly, i have a new problem that i can't solve by myself. ( I'm still trying to solve it )↵
↵
This time is with [D1](https://codeforces.me/contest/1262/problem/D1) and [D2](https://codeforces.me/contest/1262/problem/D2) problems from the last contest ( Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3 ).↵
↵
I made a solution that i think it should pass both D1 and D2 problems but i'm getting Memory limit exceeded on test 10.↵
↵
Here is my submission from D1 [code](https://codeforces.me/contest/1262/submission/65692467). The difference from D2 are the lines 89-91 because of the limits ( I only did this because i didn't know what else to do :( ).↵
↵
I think that my idea it's quite complicated to explain ( at least for me ), but i am working on it, maybe knowing what my code does someone would be able to help me..↵
↵
But, as i can see i only do $N$ insertions to the Treap and $N$ insertions to an auxiliary priority queue, i don´t have idea why i´m getting memory limit.↵
↵
I will appreciate any comment. Thank you :D