{"problem":{"name":"B. Japanese Crosswords Strike Back","description":{"content":"A one-dimensional Japanese crossword can be represented as a binary string of length _x_. An encoding of this crossword is an array _a_ of size _n_, where _n_ is the number of segments formed complete","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF884B"},"statements":[{"statement_type":"Markdown","content":"A one-dimensional Japanese crossword can be represented as a binary string of length _x_. An encoding of this crossword is an array _a_ of size _n_, where _n_ is the number of segments formed completely of 1's, and _a__i_ is the length of _i_\\-th segment. No two segments touch or intersect.\n\nFor example:\n\n*   If _x_ = 6 and the crossword is 111011, then its encoding is an array {3, 2};\n*   If _x_ = 8 and the crossword is 01101010, then its encoding is an array {2, 1, 1};\n*   If _x_ = 5 and the crossword is 11111, then its encoding is an array {5};\n*   If _x_ = 5 and the crossword is 00000, then its encoding is an empty array.\n\nMishka wants to create a new one-dimensional Japanese crossword. He has already picked the length and the encoding for this crossword. And now he needs to check if there is **exactly one** crossword such that its length and encoding are equal to the length and encoding he picked. Help him to check it!\n\n## Input\n\nThe first line contains two integer numbers _n_ and _x_ (1 ≤ _n_ ≤ 100000, 1 ≤ _x_ ≤ 109) — the number of elements in the encoding and the length of the crossword Mishka picked.\n\nThe second line contains _n_ integer numbers _a_1, _a_2, ..., _a__n_ (1 ≤ _a__i_ ≤ 10000) — the encoding.\n\n## Output\n\nPrint _YES_ if there exists **exaclty one** crossword with chosen length and encoding. Otherwise, print _NO_.\n\n[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"一维日本填字游戏可以用一个长度为 $x$ 的二进制字符串表示。该填字游戏的编码是一个长度为 $n$ 的数组 $a$，其中 $n$ 是由全 $1$ 组成的连续段的数量，而 $a_i$ 是第 $i$ 个段的长度。任意两个段都不相邻或相交。\n\n例如：\n\nMishka 想要创建一个新的二维日本填字游戏。他已经确定了该填字游戏的长度和编码。现在他需要检查是否存在 *恰好一个* 填字游戏，其长度和编码与他选定的完全一致。请帮助他验证！\n\n第一行包含两个整数 $n$ 和 $x$（$1 ≤ n ≤ 100000$，$1 ≤ x ≤ 10^9$）——编码中元素的个数以及 Mishka 选定的填字游戏长度。\n\n第二行包含 $n$ 个整数 $a_1, a_2, \\dots, a_n$（$1 ≤ a_i ≤ 10000$）——编码。\n\n如果存在 *恰好一个* 满足所选长度和编码的填字游戏，请输出 _YES_；否则输出 _NO_。\n\n## Input\n\n第一行包含两个整数 $n$ 和 $x$（$1 ≤ n ≤ 100000$，$1 ≤ x ≤ 10^9$）——编码中元素的个数以及 Mishka 选定的填字游戏长度。第二行包含 $n$ 个整数 $a_1, a_2, \\dots, a_n$（$1 ≤ a_i ≤ 10000$）——编码。\n\n## Output\n\n如果存在 *恰好一个* 满足所选长度和编码的填字游戏，请输出 _YES_；否则输出 _NO_。\n\n[samples]","is_translate":true,"language":"Chinese"},{"statement_type":"Markdown","content":"**Input Data**\n*   $n, x \\in \\mathbb{Z}$ such that $1 \\le n \\le 10^5$ and $1 \\le x \\le 10^9$.\n*   A sequence $A = (a_1, a_2, \\dots, a_n)$ where $a_i \\in \\mathbb{Z}$ and $1 \\le a_i \\le 10^4$ for all $1 \\le i \\le n$.\n\n**Definitions**\nLet $\\mathcal{S}$ be the set of valid segment starting positions $P = (p_1, p_2, \\dots, p_n) \\in \\mathbb{Z}^n$ satisfying the following system of inequalities:\n\n1.  $p_1 \\ge 1$\n2.  $p_{i+1} \\ge p_i + a_i + 1, \\quad \\forall i \\in \\{1, \\dots, n-1\\}$\n3.  $p_n + a_n - 1 \\le x$\n\n**Objective**\nDetermine the cardinality $|\\mathcal{S}|$.\n\n**Output**\n$$\n\\text{Output} = \\begin{cases} \n\\text{YES} & \\text{if } |\\mathcal{S}| = 1 \\\\\n\\text{NO} & \\text{otherwise}\n\\end{cases}\n$$","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF884B","tags":["implementation"],"sample_group":[["2 4\n1 3","NO"],["3 10\n3 3 2","YES"],["2 10\n1 3","NO"]],"created_at":"2026-03-03 11:00:39"}}