#C7093. Taco Parking Problem
Taco Parking Problem
Taco Parking Problem
You are given a parking lot with K parking spots and N cars arriving and departing at specified times. Each car is represented by an interval \((a_i, d_i)\) where \(a_i\) is the arrival time and \(d_i\) is the departure time. When a car departs, its parking spot becomes immediately available.
Your task is to determine whether all cars can park without having to wait.
Formally, you are given:
- An integer \(N\): the number of cars.
- An integer \(K\): the maximum number of parking spots available.
- A list of \(N\) intervals \((a_i, d_i)\): the arrival and departure times of each car.
Output "Yes" if at every moment in time the number of parked cars does not exceed \(K\); otherwise, output "No".
inputFormat
The first line contains two integers \(N\) and \(K\). \(N\) denotes the number of cars and \(K\) denotes the number of available parking spots. Each of the following \(N\) lines contains two integers: the arrival time and the departure time of a car.
outputFormat
Output a single line containing "Yes" if all cars can park without waiting, otherwise print "No".
## sample3 2
1 4
2 5
5 8
Yes