#K69022. Hiking Schedule Determination

    ID: 32994 Type: Default 1000ms 256MiB

Hiking Schedule Determination

Hiking Schedule Determination

You are given a vacation schedule of d days. You need to schedule exactly h hiking days out of these d days. However, some days are not available for hiking because they fall into certain closed intervals. Each closed interval is given as a pair of integers [s, e], meaning that all days from s to e (inclusive) are blocked.

Your task is to determine whether it is possible to schedule h hiking days using only the available days (i.e. the days that are not blocked by any closed interval). Formally, let \( A \) be the set of available days from \( 1 \) to \( d \). If \(|A| \geq h\), then output YES, otherwise output NO.

Input/Output Details:

The input is read from standard input and the output is written to standard output.

inputFormat

The input consists of multiple lines:

  • The first line contains three space-separated integers: d (the total number of days), h (the number of hiking days required), and n (the number of closed intervals).
  • The following n lines each contain two space-separated integers s and e, representing a closed interval from day s to day e (inclusive).

It is guaranteed that 1 ≤ d and 0 ≤ n. Closed intervals may overlap.

outputFormat

Output a single line with YES if it is possible to schedule exactly h hiking days using available days, otherwise output NO.

## sample
7 3 2
2 4
6 6
YES