Submission : https://codeforces.net/contest/1878/submission/252116337
I am new to python so I was practicing it on codeforces problems, the submission I referenced above is exceeding memory limits for very small values of $$$n$$$.
I think you don't need to really understand the problem statement, I suspect the problem is in implementation of segment tree. (as the solve() function really only has binary search which is implemented iteratively)
Any help will be appreciated
here is the code :
Spoiler