Given a row of length $N$, and a set of 1D bars having lengths $A[1...M]$, how many ways I can fill the row?
A is an integer array,
the bars are having dimensions $\{ 1\times A_1, 1\times A_2, 1\times A_3,..., 1\times A_M \}$
The row can also be considered as $1\times N$ grid.
2 Bars with equal length has to be considered as $2$ distinct bar not $1$.
Bars are same from either direction, so just by reversing bars there wont be any new arrangement
I thought solving the problem by converting it into :
Let, Each space is an element of $1\times 1$, and all spaces are indistinguishable and similar.
No of space $K=N-sum(A_1,A_2,...,A_M)$
Now the answer will be
No of arrangements of $M$ distinct elements and $K$ similar elements.
But again with no hope as could not find any solution for both the problems.
**Examples : **
$N=3, A=\{1,1\} $
$ M=2, K=1$
$Ans = 6 $
$N=3, A=\{1,2\} $
$ M=2, K=0$
$Ans = 2 $
$N=4, A=\{1,2\} $
$ M=2, K=1$
$Ans = 6 $
$N=3, A=\{2\} $
$ M=1, K=1$
$Ans = 2 $
$N=10, A=\{7\} $
$ M=1, K=3$
$Ans = 4 $