Given a matrix $A_{n\times n} = \{a_{ij}\}$ such that $a_{ij}$ is a non-negative number and given 2 vectors $(r_1,r_2,...,r_n)$ , $(c_1,c_2,...,c_n)$ such that $r_i,c_i\in \mathbb{Z}$ define an efficient algorithm that will determine if there's a matrix $B_{n\times n} = \{b_{ij}\}$ , $b_{ij} \in \mathbb{Z}$ and
for every $1\leq i \leq n \sum b_{ij} = r_i$
for every $1\leq j \leq n \sum b_{ij} = c_j$
and
$0 \leq b_{ij} \leq a_{ij}$
Thought something with dynamic programming but didn't manage to solve it.