Ensure that you are logged in and have the required permissions to access the test.

Painter's Partition

2.7

3 votes
Problem

There is fence which consists of n wooden blocks with each block having a number written on it represented by an array a. The painter is also given two numbers l and r . He is given the task to paint the fence using at most n colors. But there are certain conditions which the painter must follow while painting:

  • He has to paint the fence in sequential manner from left to right i.e, first paint the first block then second block and so on without leaving any block not being painted. 
  • He will also use colors in sequential manner i.e, first paint with 1st color,then with 2nd color and so on. Note that he can paint any number of blocks sequentially with a single color and a color once used cannot be reused.
  • The sum of numbers written on blocks painted with same color must lie between l and r ( both inclusive ).

    The painter wants to know in how many ways can he paint the fence.Since the answer can be large, find the answer modulo 1000000007.

Input Format

First line contains 3 space separated denoting the values of nl and r (1n105,1lr1012),

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

Output Format

Print the answer in a single line.

Sample Input
5 3 12
3 5 1 2 6
Sample Output
8
Time Limit: 10
Memory Limit: 256
Source Limit:
Explanation

The ways of painting are:

{(3),(5),(1,2),(6)} -> Painting 1st block with 1st color,2nd with 2nd, 3rd and 4th with 3rd and 4th block with 4th color.

{(3,5),(1,2),(6)}, {(3),(5),(1,2,6)}, {(3,5),(1,2,6)}, {(3),(5,1),(2,6)}, {(3,5,1),(2),(6)}, {(3,5,1),(2,6)}, {(3,5,1,2),(6)}

Editor Image

?