Bipartite matching doctors to hospitals
im am dealing with this question for a few days and hopefully someone can figure it out:



A hospital schedules  days ahead its  doctors' shifts. In day  i , ri  doctors must work.
Each doctor , provides the hospital a set Dj = {1,2,…n} containing the days he or she can
work.
a. Describe an algorithm that gets as input the sets Dj , , for 1<=j<=k and the requests, for 1<=i<=n. The algorithm should return (if possible) sets Lj  1<=j<=k such that:
1.   Lj is inside Dj
2. For every 1<=i<=n, day i is included in exactly ri  sets.

b. In some cases, the algorithm from section (a) announces that there is no solution.
Then,the hospital must force the doctors to work on some days that are not convenient for
them (not on their set). Suggest an algorithm for finding the minimal number c such that
the sets  satisfy the following conditions:

1. For all 1<=j<=k, Lj-Dj<= c (that is, doctor j is assigned to at most c days that are not
in his/her set of preferred days).
2. For every 1<=i<=n, day i is included in exactly ri sets.
Bipartite matching doctors to hospitals
===

im am dealing with this question for a few days and hopefully someone can figure it out:



A hospital schedules  days ahead its  doctors' shifts. In day  i , ri  doctors must work.
Each doctor , provides the hospital a set Dj = {1,2,…n} containing the days he or she can
work.
a. Describe an algorithm that gets as input the sets Dj , , for 1<=j<=k and the requests, for 1<=i<=n. The algorithm should return (if possible) sets Lj  1<=j<=k such that:
1.   Lj is inside Dj
2. For every 1<=i<=n, day i is included in exactly ri  sets.

b. In some cases, the algorithm from section (a) announces that there is no solution.
Then,the hospital must force the doctors to work on some days that are not convenient for
them (not on their set). Suggest an algorithm for finding the minimal number c such that
the sets  satisfy the following conditions:

1. For all 1<=j<=k, Lj-Dj<= c (that is, doctor j is assigned to at most c days that are not
in his/her set of preferred days).
2. For every 1<=i<=n, day i is included in exactly ri sets.