The D. E. Shaw GroupOA #11
Array Break
Estimated HardJudge-ready
Topics (AI-labelled)DP BasicsPrefix & Ranges
Given a positive integer array arr, count the pairs of non-negative integer arrays b and c, both of length n, such that b is non-decreasing, c is non-increasing, and b[i]+c[i]=arr[i] for every i. Output the answer modulo 1000000007.
The standard input/output, the ranges added by this site, and the examples follow this problem's description.
Input
The first line contains n (1≤n≤3000); the second line contains n integers (1≤arr[i]≤3000). The ranges and the modulus are taken from the original problem's constraints.
Output
Output the number of ordered array pairs (b,c) that satisfy the conditions, modulo 1000000007.
Example 1
Input:
3
2 3 2
Output:
4
Example 2
Input:
2
3 2
Output:
6
Example 3
Input:
1
1
Output:
2
Editorial
Loading solution…