100 atcoder#ABC185B. [ABC185B] Smartphone Addiction

[ABC185B] Smartphone Addiction

Score : 200200 points

Problem Statement

The battery of Takahashi's smartphone has NN mAh capacity. At time 0.50.5, 1.51.5, 2.52.5, and so on (that is, at time n+0.5n + 0.5 for every integer nn), the battery charge decreases by 11 mAh. Takahashi will leave his house with his phone fully charged at time 00, visit a cafe MM times, and return home at time TT. He will stay at the ii-th cafe from time AiA_i to time BiB_i. During this stay, he charges his phone, so the battery charge does not decrease. Instead, at time n+0.5n + 0.5 for every integer nn, it increases by 11. However, if it is already equal to the battery capacity, it does not increase nor decrease. Determine whether he can return home without the battery charge dropping to 00 on the way.

Constraints

  • 1N1091 \le N \le 10^9
  • 1M10001 \le M \le 1000
  • 1T1091 \le T \le 10^9
  • $0 \lt A_1 \lt B_1 \lt A_2 \lt B_2 \lt A_3 \lt B_3 \lt \dots \lt A_M \lt B_M \lt T$
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN MM TT

A1A_1 B1B_1

A2A_2 B2B_2

A3A_3 B3B_3

\hspace{15pt} \vdots

AMA_M BMB_M

Output

If Takahashi can return home without the battery charge dropping to 00 on the way, print Yes; otherwise, print No.

10 2 20
9 11
13 17
Yes

The battery charge changes as follows:

  • Time 00 (leaving home): 1010 mAh
  • Time 99 (the beginning of the stay at the first cafe): 11 mAh
  • Time 1111 (the end of the stay at the first cafe): 33 mAh (He charges his phone in a cafe.)
  • Time 1313 (the beginning of the stay at the second cafe): 11 mAh
  • Time 1717 (the end of the stay at the second cafe): 55 mAh
  • Time 2020 (getting home): 22 mAh

During this process, the battery charge never drops to 00, so we print Yes.

10 2 20
9 11
13 16
No

This case is the same as Sample Input/Output 1 until he starts his stay at the second cafe with 11 mAh charge. When he ends his stay there at time 1616, the battery charge is 44 mAh. Then at time 19.519.5, it drops to 00, so we print No.

15 3 30
5 8
15 17
24 27
Yes

The battery charge drops to 11 mAh when he gets home, but it never drops to 00 on the way.

20 1 30
20 29
No

The battery charge drops to 00 at time 19.519.5.

20 1 30
1 10
No

Note that when the battery charge is equal to the battery capacity, staying at a cafe does not increase the battery charge.