#abc240c. C - Jumping Takahashi

C - Jumping Takahashi

Score : 300300 points

问题描述

高桥站在数轴上的坐标 00 处。

他现在将进行 NN 次跳跃。在第 ii 次跳跃中 (1iN)(1 \leq i \leq N),他会向正方向移动 aia_i 或者 bib_i

请问,在经过 NN 次跳跃后,他能否到达坐标 XX

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

Takahashi is standing at the coordinate 00 on a number line.

He will now perform NN jumps. In the ii-th jump (1iN)(1 \leq i \leq N), he moves aia_i or bib_i in the positive direction.

Is it possible for him to be at the coordinate XX after NN jumps?

Constraints

  • 1N1001 \leq N \leq 100
  • 1ai<bi100(1iN)1 \leq a_i \lt b_i \leq 100 \, (1 \leq i \leq N)
  • 1X100001 \leq X \leq 10000
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN XX

a1a_1 b1b_1

\vdots

aNa_N bNb_N

Output

If it is possible for Takahashi to be at the coordinate XX after NN jumps, print Yes; otherwise, print No.

Sample Input 1

2 10
3 6
4 5

Sample Output 1

Yes

By moving b1(=6)b_1 (= 6) in the first jump and a2(=4)a_2 (= 4) in the second jump, he can be at the coordinate X(=10)X (= 10).

Sample Input 2

2 10
10 100
10 100

Sample Output 2

No

He can be at the coordinate X(=10)X (= 10) after the first jump, but not after all jumps.

Sample Input 3

4 12
1 8
5 7
3 4
2 6

Sample Output 3

Yes

update @ 2024/3/10 10:20:37