1

Given a value n and number of parts d. Each part has max and min values it can have.

Is it possible to divide n in d parts fullfilling the max and min value criteria ? Example

d=2 n=5

Part 1 range-> 0 to 1 Part 2 range -> 3 to 5. Answer is YES . Part1 can have value 1 and Part2 can have value 4

1 Answers1

0

This clearly depends on the given ranges. Let's fix some notation: We have a given number $n$, which is to be split into $d$ parts, where the $i$-th part has to have a value between $\ell_i$ and $u_i$ (inclusive).

Your example would be $n = 5$, $d = 2$, $\ell_1 = 0$, $u_1 = 1$, $\ell_2 = 3$, $u_2 = 5$.

Another example would be $n = 20$, $d = 3$, $\ell_1 = \ell_2 = \ell_3 = 0$, $u_1 = 5$, $u_2 = 6$, $u_3 = 7$. This does not have a solution: Assume that $p_1, p_2$ and $p_3$ are given such that $0 \le p_1 \le 5$,$0 \le p_2 \le 6$, $0 \le p_3 \le 7$. Then we clearly have $p_1 + p_2 + p_3 \le 5 + 6 + 7 = 18 < 20$, so $p_1 + p_2 + p_3 \neq n$.

More generally, we can divide $n$ in $d$ parts as above if $\sum_{i=1}^d \ell_i \le n \le \sum_{i=1}^d u_i$.