{"problem":{"name":"A. Visiting a Friend","description":{"content":"Pig is visiting a friend. Pig's house is located at point 0, and his friend's house is located at point _m_ on an axis. Pig can use teleports to move along the axis. To use a teleport, Pig should c","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF902A"},"statements":[{"statement_type":"Markdown","content":"Pig is visiting a friend.\n\nPig's house is located at point 0, and his friend's house is located at point _m_ on an axis.\n\nPig can use teleports to move along the axis.\n\nTo use a teleport, Pig should come to a certain point (where the teleport is located) and choose where to move: for each teleport there is the rightmost point it can move Pig to, this point is known as the limit of the teleport.\n\nFormally, a teleport located at point _x_ with limit _y_ can move Pig from point _x_ to any point within the segment \\[_x_; _y_\\], including the bounds.\n\n<center>![image](https://espresso.codeforces.com/ac5b7c8a91aa8756da17036e40160876c65231c3.png)</center>Determine if Pig can visit the friend using teleports only, or he should use his car.\n\n## Input\n\nThe first line contains two integers _n_ and _m_ (1 ≤ _n_ ≤ 100, 1 ≤ _m_ ≤ 100) — the number of teleports and the location of the friend's house.\n\nThe next _n_ lines contain information about teleports.\n\nThe _i_\\-th of these lines contains two integers _a__i_ and _b__i_ (0 ≤ _a__i_ ≤ _b__i_ ≤ _m_), where _a__i_ is the location of the _i_\\-th teleport, and _b__i_ is its limit.\n\n**It is guaranteed that _a__i_ ≥ _a__i_ - 1 for every _i_ (2 ≤ _i_ ≤ _n_)**.\n\n## Output\n\nPrint \"_YES_\" if there is a path from Pig's house to his friend's house that uses only teleports, and \"_NO_\" otherwise.\n\nYou can print each letter in arbitrary case (upper or lower).\n\n[samples]\n\n## Note\n\nThe first example is shown on the picture below:\n\n<center>![image](https://espresso.codeforces.com/97af9c02f6fbd10e07baa36e74770261d93d5c70.png)</center>Pig can use the first teleport from his house (point 0) to reach point 2, then using the second teleport go from point 2 to point 3, then using the third teleport go from point 3 to point 5, where his friend lives.\n\nThe second example is shown on the picture below:\n\n<center>![image](https://espresso.codeforces.com/122f57806a14b001c70f0ae56f5369c9a3867820.png)</center>You can see that there is no path from Pig's house to his friend's house that uses only teleports.","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"Pig 正在拜访一位朋友。\n\nPig 的房子位于点 #cf_span[0]，他的朋友的房子位于数轴上的点 #cf_span[m]。\n\nPig 可以使用传送装置沿数轴移动。\n\n要使用传送装置，Pig 必须先到达该传送装置所在的位置，并选择移动到何处：每个传送装置都有一个最远可将 Pig 传送到的点，该点被称为该传送装置的极限。\n\n形式上，位于点 #cf_span[x] 且极限为 #cf_span[y] 的传送装置，可以将 Pig 从点 #cf_span[x] 传送到区间 #cf_span[[x; y]] 内的任意点，包括端点。\n\n判断 Pig 是否仅通过传送装置即可拜访朋友，还是必须使用汽车。\n\n第一行包含两个整数 #cf_span[n] 和 #cf_span[m]（#cf_span[1 ≤ n ≤ 100, 1 ≤ m ≤ 100]）——传送装置的数量和朋友家的位置。\n\n接下来的 #cf_span[n] 行描述了每个传送装置的信息。\n\n第 #cf_span[i] 行包含两个整数 #cf_span[ai] 和 #cf_span[bi]（#cf_span[0 ≤ ai ≤ bi ≤ m]），其中 #cf_span[ai] 是第 #cf_span[i] 个传送装置的位置，#cf_span[bi] 是其极限。\n\n*保证对于每个 #cf_span[i]（#cf_span[2 ≤ i ≤ n]），都有 #cf_span[ai ≥ ai - 1]*。\n\n如果存在一条仅使用传送装置从 Pig 的家到朋友家的路径，则输出 \"_YES_\"，否则输出 \"_NO_\"。\n\n你可以以任意大小写形式输出每个字母。\n\n第一个示例如下图所示：\n\nPig 可以从家（点 #cf_span[0]）使用第一个传送装置到达点 #cf_span[2]，然后使用第二个传送装置从点 #cf_span[2] 移动到点 #cf_span[3]，再使用第三个传送装置从点 #cf_span[3] 移动到点 #cf_span[5]，即他朋友的家。\n\n第二个示例如下图所示：\n\n你可以看到，不存在一条仅使用传送装置从 Pig 的家到朋友家的路径。\n\n## Input\n\n第一行包含两个整数 #cf_span[n] 和 #cf_span[m]（#cf_span[1 ≤ n ≤ 100, 1 ≤ m ≤ 100]）——传送装置的数量和朋友家的位置。接下来的 #cf_span[n] 行描述了每个传送装置的信息。第 #cf_span[i] 行包含两个整数 #cf_span[ai] 和 #cf_span[bi]（#cf_span[0 ≤ ai ≤ bi ≤ m]），其中 #cf_span[ai] 是第 #cf_span[i] 个传送装置的位置，#cf_span[bi] 是其极限。*保证对于每个 #cf_span[i]（#cf_span[2 ≤ i ≤ n]），都有 #cf_span[ai ≥ ai - 1]*。\n\n## Output\n\n如果存在一条仅使用传送装置从 Pig 的家到朋友家的路径，则输出 \"_YES_\"，否则输出 \"_NO_\"。你可以以任意大小写形式输出每个字母。\n\n[samples]\n\n## Note\n\n第一个示例如下图所示：  Pig 可以从家（点 #cf_span[0]）使用第一个传送装置到达点 #cf_span[2]，然后使用第二个传送装置从点 #cf_span[2] 移动到点 #cf_span[3]，再使用第三个传送装置从点 #cf_span[3] 移动到点 #cf_span[5]，即他朋友的家。第二个示例如下图所示：  你可以看到，不存在一条仅使用传送装置从 Pig 的家到朋友家的路径。","is_translate":true,"language":"Chinese"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ n, m \\in \\mathbb{Z}^+ $ with $ 1 \\leq n \\leq 100 $, $ 1 \\leq m \\leq 100 $.  \nLet $ T = \\{(a_i, b_i) \\mid i \\in \\{1, \\dots, n\\}\\} $ be a set of teleports, where:  \n- $ a_i \\in \\mathbb{Z} $ is the location of teleport $ i $,  \n- $ b_i \\in \\mathbb{Z} $ is its limit, satisfying $ 0 \\leq a_i \\leq b_i \\leq m $,  \n- and $ a_i \\geq a_{i-1} $ for all $ i \\in \\{2, \\dots, n\\} $.\n\n**Constraints**  \n1. Pig starts at point $ 0 $.  \n2. Goal is to reach point $ m $.  \n3. From any point $ x \\in [a_i, b_i] $, a teleport $ (a_i, b_i) $ allows movement to any point in $ [a_i, b_i] $.  \n4. Pig may only use a teleport if he is already at or beyond its location $ a_i $.\n\n**Objective**  \nDetermine whether there exists a sequence of teleport uses starting from $ 0 $ and ending at $ m $, such that each transition stays within the bounds of some teleport.  \n\nEquivalently:  \nLet $ r $ be the maximum reachable point starting from $ 0 $.  \nInitialize $ r = 0 $.  \nFor each teleport $ (a_i, b_i) $ in order:  \n- If $ a_i > r $, return \"NO\".  \n- Else, update $ r = \\max(r, b_i) $.  \nIf $ r \\geq m $, return \"YES\"; otherwise, \"NO\".","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF902A","tags":["greedy","implementation"],"sample_group":[["3 5\n0 2\n2 4\n3 5","YES"],["3 7\n0 4\n2 5\n6 7","NO"]],"created_at":"2026-03-03 11:00:39"}}