Partitions
Practice
3.9 (13 votes)
Algorithms
Binary search
Medium
Searching
Partitions
Problem
24% Success 2992 Attempts 30 Points 5s Time Limit 256MB Memory 1024 KB Max Code

You are given an array $$a$$ of size $$n$$ and two integers $$l$$ and $$r$$. You have to find the number of partitions of array $$a$$ such that the sum of elements in each partition lies between $$l$$ and $$r$$(both inclusive). Since the answer can be large, find the answer modulo $$10^9+7$$ ($$1000000007$$).

Input Format

First line contains \(3\) space separated denoting the values of $$n$$, $$l$$ and $$r$$ ($$ 1 \le n \le 10^5 $$, $$ 1 \le l \le r \le 10^{12} $$).

Next line contains $$n$$ space separated integers denoting the values of array $$a$$ ($$ 1 \le a[i] \le r$$).

Output Format

Print the answer in a single line.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
6 votes
Tags:
Binary SearchBit ManipulationMedium
Points:30
17 votes
Tags:
AlgorithmsBinary SearchGreedy AlgorithmsMediumSearchingmedium
Points:30
8 votes
Tags:
AlgorithmsBinary SearchHiringImplementationMediumSearchingString Manipulation