We are given m positive integers, n1, n2, …, nm, with the property that n1 >= n2 >=… >= nm > 0.
We call a Young array a setup of n1+n2+…+nm distinctive non-zero positive integers in an array so that each line i has ni elements (1 <= i <= m) in ascending order, from left to right, and elements on the same column are in ascending order from the top down.
An example of a Young array for m=4, n1=6, n2=4, n3=4, n4=1 is:
1 | 2 | 5 | 9 | 10 | 15 |
3 | 6 | 7 | 13 | ||
4 | 8 | 12 | 14 | ||
11 |
Task
For given n1, n2, …, nm, determine how many Young arrays comprised of elements 1, 2, …, n1+n2+…+nm can be made.
Input Data
Output file young.in contains on line one positive integer m, and on line two numbers n1, n2, …, nm, each separated by a space.
Output Data
Output file young.out will contain a single line with the number of Young arrays that can be formed.
Restrictions
young.in | young.out | Explanation |
2 3 2 |
5 |
The 5 Young arrays that can be created are: |
Time limit: 0.1 seconds/test
prof. Doru Popescu Anastasiu
"Radu Greceanu" Slatina National High School
Contact:dopopan@yahoo.com