#K91947. Exam Room Allocation
Exam Room Allocation
Exam Room Allocation
You are given several datasets describing exam requirements and available room capacities. For each dataset, the first line contains two integers \(E\) and \(R\) representing the number of exams and number of available rooms respectively. The second line contains \(E\) space‐separated integers where each integer is the number of students registered for an exam. The third line contains \(R\) space‐separated integers representing the seating capacity of each room.
Your task is to determine whether it is possible to assign a unique room to every exam such that the room's capacity is at least equal to the number of students taking that exam, i.e. if \(s\) is the number of students for an exam and \(r\) is the capacity of a room then \(r \ge s\). The input terminates with a line containing "0 0".
Note: Each exam can only be assigned exactly one room, and each room can only be used for at most one exam.
inputFormat
The input is read from standard input (stdin) and is composed of several datasets. Each dataset consists of three lines:
- The first line contains two integers \(E\) and \(R\) (\(1 \leq E, R \leq 1000\)), denoting the number of exams and the number of available rooms, respectively.
- The second line contains \(E\) space-separated integers indicating the number of students in each exam.
- The third line contains \(R\) space-separated integers indicating the capacity of each room.
The input terminates with a line containing "0 0" which should not be processed.
outputFormat
For each dataset, output a single line to standard output (stdout) that contains either "Yes" if it is possible to allocate rooms to all exams, or "No" otherwise.
The decision is based on the condition that every exam must be assigned a room whose capacity is at least equal to the number of students taking that exam \( (r \ge s) \).
## sample3 4
40 25 35
50 30 40 20
2 2
20 30
25 15
2 2
30 40
20 30
0 0
Yes
No
No
</p>