#P6936. Photography Scheduling

    ID: 20143 Type: Default 1000ms 256MiB

Photography Scheduling

Photography Scheduling

You are given (n) features along with the ideal time windows (\left[a_i, b_i\right]) for taking photographs. Each photograph takes (d) units of time. Determine if it is possible to schedule photographs for all features in one day. More formally, you need to decide whether there exists an ordering of tasks such that if you start at time (t) and for each feature you update (t = \max(t, a_i) + d), the condition (\max(t, a_i) + d \le b_i) holds for every feature. Use an appropriate scheduling strategy to check if all photographs can be taken successfully.

inputFormat

The first line contains two integers (n) and (d) --- the number of features and the time required to take one photograph. Each of the next (n) lines contains two integers (a_i) and (b_i), denoting the earliest and the latest times at which the (i)th feature can be photographed, respectively.

outputFormat

Print (yes) if it is possible to schedule photographs for all features within their time windows, and (no) otherwise.

sample

3 10
0 30
25 60
60 90
yes