# Add on interval, Query for number of elements less than val

We have an array of numbers and we are supposed to do the following queries on it:

1. Add number x to all elements on the subarray with indices [ L, R ] of the array.
2. Query for number of elements less than number x of 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?