[F2] Exam scheduling (2 pts) [00S8]

Given a list of n classes, a list of r rooms, a list of t time slots, and a list of a therapy animals, our goal is to assign the final exam for each class to a particular room at a particular time, with a visit from one of a list of therapy animals.

  • Each class i has a size S_i.
  • Each room j has a capacity C_j; classes may only be assigned to rooms that are large enough to fit them, that is, if S_i \leq C_j.
  • Each room is only available during some of the time slots, and may have at most one class assigned to it per time slot.
  • Each therapy animal is only available during certain time slots, and an animal may only visit one exam per time slot.
  • To avoid overwhelming the therapy animals, each animal may be assigned to visit a maximum of three exams.

Design an algorithm to find a valid way to assign each class to a room, time, and therapy animal that satisfies all the constraints (or report that no such assignment is possible). Be sure to justify the correctness of your algorithm and analyze its asymptotic running time.