{"trustable":false,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n section pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n {left: \u0027\\\\[\u0027, right: \u0027\\\\]\u0027, display: true}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"Problem Statement","value":{"format":"HTML","content":"\u003cp\u003e给出一个序列 A\u003csub\u003e1\u003c/sub\u003e,A\u003csub\u003e2\u003c/sub\u003e,...,A\u003csub\u003eN\u003c/sub\u003e 和一个整数 K。\u003c/p\u003e\n\u003cp\u003e打印满足下列条件的序列B的最大可能长度。\u003c/p\u003e\n\u003cp\u003eB是A的(不一定是连续的)子序列。\u003c/p\u003e\n\u003cp\u003e对于B的每一对相邻元素,元素的绝对差最多为K。\u003c/p\u003e\n"}},{"title":"Constraints","value":{"format":"HTML","content":"\u003cp\u003e1 \u0026lt;\u003d N \u0026lt;\u003d 300,000\u003c/p\u003e\n\u003cp\u003e0 \u0026lt;\u003d A\u003csub\u003ei\u003c/sub\u003e \u0026lt;\u003d 300,000\u003c/p\u003e\n\u003cp\u003e0 \u0026lt;\u003d K \u0026lt;\u003d 300,000\u003c/p\u003e\n"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eInput is given from Standard Input in the following format:\u003c/p\u003e\n\u003cp\u003eN K\u003c/p\u003e\n\u003cp\u003eA\u003csub\u003e1\u003c/sub\u003e\u003c/p\u003e\n\u003cp\u003eA\u003csub\u003e2\u003c/sub\u003e\u003c/p\u003e\n\u003cp\u003e:\u003c/p\u003e\n\u003cp\u003eA\u003csub\u003eN\u003c/sub\u003e\u003c/p\u003e\n"}},{"title":"Output","value":{"format":"HTML","content":"Print the answer."}},{"title":"Sample Input 1","value":{"format":"HTML","content":"\u003ch3\u003e\u003c/h3\u003e\n\u003cpre\u003e10 3\n1\n5\n4\n3\n8\n6\n9\n7\n2\n4\n\u003c/pre\u003e"}},{"title":"Sample Output 1","value":{"format":"HTML","content":"\u003cp\u003eFor example, B \u003d (1, 4, 3, 6, 9, 7, 4) satisfies the conditions.\u003c/p\u003e\n\u003cp\u003eIt is a subsequence of A \u003d (1, 5, 4, 3, 8, 6, 9, 7, 2, 4).\u003c/p\u003e\n\u003cp\u003eAll of the absolute differences between two adjacent elements (|1-4|, |4-3|, |3-6|, |6-9|, |9-7|, |7-4|) are \u003c/p\u003e\n\u003cp\u003eat most K \u003d 3.\u003c/p\u003e\n"}}]}