A dynamic programming problema on containers and product
Here is one approach, I could think of. 

$T(x, y) = $ The maximum number of products which could be put into containers if we start at position $x$ in container line, whereas position $y$ in the product line.

If $size(C_x) &gt;= size(P_y)$ we can either choose or skip the container. Else if the size of container is smaller, since we cannot skip the product, we would have to skip the container.

Hence, the recursion would be:
\begin{equation}
  T[x, y]=\begin{cases}
    max(1 + T[x+1,\hspace{1mm} y+1], \hspace{2mm} T[x+1,\hspace{1mm} y]), &amp; \text{if $size(C_x) &gt;= size(P_y)$}.\\
    T[x+1,\hspace{1mm}y], &amp; \text{otherwise}.
  \end{cases}
\end{equation}

Starting from the end of both the arrays, $$max(T[1,i]) \hspace{2mm}: \hspace{2mm} 1&lt;=i&lt;=n$$ should have the required result. 

http://ideone.com/3dsrZu