I saw a few submissions at the top of the leaderboard and I don’t think they are using divide and conquer. My solution is quite similar to these and the only things used are prefix sums and binary search.
Let us call the input array A and let S_{i,j} = \sum_{k=i}^j A_k. Now consider all the subarray sums:
S_{1,1}, S_{1,2}, S_{1,3}, \cdots , S_{1,N} \\
S_{2,2}, S_{2,3}, \cdots, S_{2,N} \\
\vdots \\
S_{N-1,N-1}, S_{N-1,N} \\
S_{N,N}
When arranged in this particular order, observe that each row is a sorted sequence (there are no negative numbers in A).
How does this help? If you construct the prefix sum array you can access all these sums in constant time, so you effectively have these N sorted sequences ready for use.
Now given a value x you can binary search on these N sequences to count how many elements in each sequence are \le x. If you add these counts up, you can get the total number of sums S_{i,j} which are \le x.
Next you can binary search on x to find the element at index k in the sorted sequence of all S_{i,j}.
And if you know this element at k, you can also find the sum of all S_{i,j} which are \le this element using a prefix sum array of the initial prefix sum array.
Now the final step is just to compute this sum for k=R and k=L-1 separately and print the difference. The total complexity is \mathcal{O}(Q \cdot N \cdot \log{N} \cdot \log{100N}), where the 100 is the limit on the maximum value of an element of A.

