There are a total of $n$ objects in stock. You must keep at least $c_i$ objects in stock at location $i$. Assume $n \ge \sum c_i$.
a.) How many different inventories $(x_1,x_2,\dots,x_r)$ are there?
b.) Each location can store a maximum of $d_i$. Let $r = 2$ and count the number of different invetories $(x_1,x_2)$ with $c_1 \le x_1 \le d_1$ and $c_2 \le x_2 \le d_2$.
My answer for part a: We have no choice over where $c_1 + c_2 + \dots + c_r = c_t$ objects are placed. The ramaining $n-c_t$ objects can be spread across $r$ locations. So, there are $$\binom{(n-c_t) + r - 1}{r-1}$$ different inventories.
My incomplete answer for part b: After placing minimum required objects at each location, we are left with $n-c_1-c_2$ objects to distribute.
The remaining objects can be distributed in $$\binom{(n-c_1-c_2)+2-1}{2-1} = (n-c_1-c_2)+1.$$
Now from the number above, I need to subtract the number of combinations that lead to overflows in the two locations.
[---Not sure if the rest is correct---]
Number of ways location 1 overflows:
Location 1 overflows when $x_1 > d_1$ and $c_2 \le x_2 \le d_2$:
$$\binom{(n-(d_1+1)-c_2)+2-1}{2-1} = n-d_1-c_2$$
Number of ways location 2 overflows:
(same reasoning as above)
$$n-d_2-c_1$$
Total number of inventories is $$(n-c_1-c_2+1)-[(n-d_1-c_2)+(n-d_2-c_1)] = (d_1+d_2+1)-n$$
Total number of inventories $= (d_1+d_2+1)-n$ doesn't make sense.
Please help me figure out where I went wrong.