Test Data Analysis
Time limit2sMemory limit256 MB
Count bounded arrays of length N whose maximum contiguous subarray sum equals D, modulo 1,000,000,007.
- Level
Hard8 of 10
- Topics
- Dynamic programming, Prefix sum, Combinatorics
- Solved
- No attempts yet
Problem
For an array of length , the maximum subarray problem asks for the largest sum of any contiguous subarray.
Each position must satisfy . Count how many different arrays have maximum subarray sum exactly . Print the count modulo .
Input
The first line contains an integer , the number of test cases.
Each test case begins with integers and (, ).
The next lines give and () for each position.
Output
For each test case, print one line with the number of valid arrays modulo .
Note
When and every range is with , exactly 12 arrays reach maximum subarray sum 3.