Number of ways to choose balls The context of the problem is different but I'll try to describe using red and black balls. 
Let say we have 5 boxes with red and black balls and we take one from each box.
The number of ways to get only red balls is $r_1 \cdot r_2 \cdot r_3 \cdot r_4 \cdot r_5$ where r is the number of red balls in the each box. If we want to get exactly 3 red and 2 black balls the number of ways is the sum of 10  products $(r_1 \cdot r_2 \cdot r_3 \cdot b_4 \cdot b_5 ) + ( r_1 \cdot r_2 \cdot b_3 \cdot r_4 \cdot b_5 ) + \cdot \cdot \cdot + ( b_1 \cdot b_2 \cdot r_3 \cdot r_4 \cdot r_5)$.
Now I have a slightly different problem. Each box has red, black and some other balls that we don't know yet the color (red or black). The number of balls with unknown colors is $q$.
If we take one ball from each box and we want all to be red, the maximum number of possible ways now is $(r_1+q_1)(r_2+q_2)(r_3+q_3)$...since each unknown color can be red. 
My question is what is the maximum number of ways to get 3 red and 2 black balls in the second version?
So, from all combinations of balls $N = (r_1+b_1+q_1)(r_2+b_2+q_2)\cdots(r_5+b_5+q_5)$, how many of them are candidates to have 3 red and 2 black balls?
 A: This answer is based mainly on a reading of the last sentence of the
question, which seems to imply that for each of the $N$ possible
combinations of balls, if there is a color assignment to the unknown balls
that makes three red and two blue, we count that combination.
If the actual question is how to color the "unknown" balls
so that the chance of three red and two blue is maximized
(that is, to put $r'_i$ red and $b'_i$ blue balls in box $i$ such
that $r'_i\geq r_i$, $b'_i\geq b_i$, and $r'_i + b'_i = r_i + b_i + q_i$
so as to maximize the number of combinations of three red and two blue),
the following won't be of much use.

As a way of reducing this to a more familiar problem,
let $R$ be the number of already known red balls among the five you select,
$B$ be the number of already known blue balls among the five you select,
and $Q$ the number of "unknown color" balls among the five you select.
For any particular value assignment to $R$, $B$, and $Q$, 
for example, $R=1$, $B=1$, $Q=3$, you can
determine how many ways there are to select balls in that way.
So you can calculate the number of combinations for each of the following
possibilities:
\begin{align}
R &= 3,& B &= 2,& Q &= 0 \\
R &= 3, &B &= 1,& Q &= 1 \\
R &= 2, &B &= 2,& Q &= 1 \\
R &= 3, &B &= 0,& Q &= 2 \\
R &= 2, &B &= 1,& Q &= 2 \\
R &= 1, &B &= 2,& Q &= 2 \\
R &= 2, &B &= 0,& Q &= 3 \\
R &= 1, &B &= 1,& Q &= 3 \\
R &= 0, &B &= 0,& Q &= 3 \\
R &= 1,& B &= 0,& Q &= 4 \\
R &= 0,& B &= 1,& Q &= 4 \\
R &= 0,& B &= 0,& Q &= 5 \\
\end{align}
That's an exhaustive and mutually-exclusive list of possible ways
the you might draw balls of which it happens that three
are red and two are blue.
Perhaps the calculation can be simplified further, but this 
format at least seems practical.
