#K37902. Course Scheduling Verification

    ID: 26079 Type: Default 1000ms 256MiB

Course Scheduling Verification

Course Scheduling Verification

You are given a set of courses and classrooms along with their respective constraints. Each course requires a specific number of student slots and has a limited number of available time slots during the week. Similarly, each classroom has a certain capacity and is available for a given number of time slots.

There are a total of \( t \) time slots in a week. A course can only be scheduled in one of its available time slots (i.e. from time slot \( 0 \) to \( available\_slots - 1 \)). In a particular time slot, a classroom may host at most one course, and it can only be used if its capacity is at least the number of students needed by the course.

Your task is to determine whether it is possible to assign each course to a time slot and a classroom so that every course can be accommodated.

inputFormat

The first line contains three integers \( c \), \( r \), and \( t \), where:

  • \( c \) is the number of courses.
  • \( r \) is the number of classrooms.
  • \( t \) is the total number of time slots available in a week.

The next \( c \) lines each contain two integers representing a course's requirements:

  • The required number of student slots.
  • The number of available time slots for that course.

The following \( r \) lines each contain two integers representing a classroom's details:

  • The classroom capacity.
  • The number of time slots in which the classroom is available.

outputFormat

Output a single line: "YES" if it is possible to schedule all courses under the given constraints, or "NO" otherwise.

## sample
3 2 10
30 4
15 2
20 5
50 7
25 4
YES