We have an array of numbers and we are supposed to do the following queries on it:
- Add number
xto all elements on the subarray with indices
[ L, R ]of the array.
- Query for number of elements less than number
xof the whole array.
I have a solution with time complexity $ O(q \cdot log(n) \cdot sqrt(n))$ where $ n$ is the size of the array and $ q$ is the number of the queries. However for constraints $ n, q < 1e5$ with time limit of 2 seconds this is not efficient enough. So how to solve it on these constraints?