#P9556. Factory Orders Fulfillment
Factory Orders Fulfillment
Factory Orders Fulfillment
A factory receives \( n \) orders at the beginning of day \( 1 \). The \( i\)-th order is represented by two integers \( a_i \) and \( b_i \), meaning that by the end of day \( a_i \) the factory must deliver \( b_i \) products to the customer.
The factory can produce \( k \) products each day and starts with no products in stock at the beginning of day \( 1 \). Determine if the factory can complete all orders.
Note: The factory can accumulate products over days. That is, products produced on earlier days can be used to fulfill later orders.
inputFormat
The first line contains two integers \( n \) and \( k \) (the number of orders and the daily production capacity, respectively).
Each of the next \( n \) lines contains two integers \( a_i \) and \( b_i \), representing the deadline (day) and the number of products needed for the \( i\)-th order.
outputFormat
Output a single line containing Yes
if the factory can fulfill all orders, or No
otherwise.
sample
3 3
3 5
2 3
4 4
Yes