Subarray Sum In Range

Hard
ArrayPrefix SumBinary Indexed TreeContest
Given n integers and two integers L and R (L <= R), count the number of contiguous non-empty subarrays whose sum S satisfies L <= S <= R. Input format: - First line: n L R - Second line: n integers Print a single integer. Prefix sums can be large, and the answer can exceed a 32-bit integer.

Constraints

1 <= n <= 10^5
-10^9 <= nums[i] <= 10^9
-10^14 <= L <= R <= 10^14

Sample tests

Sample 1

Sample 2

Sign in to submit