There are two rooms (A and B) and $n$ people.
Each person i in $[1,n]$ supplies two non-negative numbers: $A_i$ and $B_i$, such that $A_i+B_i=n$.
The number $A_i$ can be interpreted as saying "I am willing to be in room A as long as there are at most $A_i$ people in it", and similarly $B_i$ for room B.
Now, we want to put $k$ people in room A, and $n-k$ people in room B, such that:
- For each person $i$ in room A: $A_i \geq k$
- For each person $j$ in room B: $B_j \geq n-k$
Is this always possible? If so, what is the way to find $k$?
Additionally, I will be happy to know if this question has a general name, or is a part of a general theory.