#K77797. Scheduling Appointments for Interviewers and Applicants

    ID: 34944 Type: Default 1000ms 256MiB

Scheduling Appointments for Interviewers and Applicants

Scheduling Appointments for Interviewers and Applicants

You are given a set of interviewers and a set of applicants. Each interviewer is available during a specific time interval, and each applicant requests an appointment starting at a given time and lasting a certain duration.

Your task is to determine whether it is possible to schedule all applicant appointments by assigning each applicant to a different interviewer whose available interval fully covers the applicant's requested time slot.

Formally, if an interviewer is available from \( s_i \) to \( e_i \) and an applicant requests an appointment starting at \( a_j \) with duration \( d_j \), then the appointment can be scheduled with that interviewer if and only if:

\( s_i \leq a_j < e_i \) and \( a_j + d_j \leq e_i \).

Once an interviewer is assigned to an applicant, that interviewer cannot be used for another appointment.

Output YES if all appointments can be scheduled and NO otherwise.

inputFormat

The first line contains two integers \( I \) and \( A \) (0 \( \leq I, A \leq 10^5 \)): the number of interviewers and applicants respectively.

The next \( I \) lines each contain two integers representing the start and end times of an interviewer's availability.

The following \( A \) lines each contain two integers representing an applicant's requested start time and the duration of the appointment.

outputFormat

Output a single line containing YES if all appointments can be scheduled, or NO if not.

## sample
3 2
60 120
180 240
300 360
90 30
200 20
YES