We are given ($a_1,a_2,....,a_m$) and ($b_1, b_2,....,b_n$) sequences with non-negative integers.
Decide whether it's possible and if it is construct a matrix $\Re^{m x n}$ of ones("1") and zeros("0") where the number of ones("1") in row $i$ is $\forall i $ : $a_i$ and in column $j$ is $\forall j$ : $b_j$
Any hint is greatly appreciated.
The answer to this innocent-looking problem is a well-known and nontrivial result in combinatorics, the Gale-Ryser theorem (see, for example, http://compalg.inf.elte.hu/~tony/Kutatas/EGHH/Gale-Ryser-Krause-1966.pdf).