{"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":"MD","content":"现在给你一个由1到n的整数的一种排列所组成的数组,即1到n每个数都出现了一次,然后给你一个限制k,接下来你只有一种操作:选取位置相邻的k个数,把它们都变成这k个里面最小的\n\n那么,至少要多少次操作才能让所有数都变成1呢?"}},{"title":"Constraints","value":{"format":"MD","content":"2 \u003c\u003d k \u003c\u003d n \u003c\u003d 100000"}},{"title":"Input","value":{"format":"MD","content":"第一行输入n和k\n第二行依次输入这个数组的n个元素\n"}},{"title":"Output","value":{"format":"MD","content":"输出至少的操作次数"}},{"title":"Sample Input 1","value":{"format":"MD","content":"\u003ch3\u003e\u003c/h3\u003e\n\u003cpre\u003e4 3\n2 3 1 4\n\u003c/pre\u003e"}},{"title":"Sample Output 1","value":{"format":"MD","content":"\u003ch3\u003e\u003c/h3\u003e\n\u003cpre\u003e2\n\u003c/pre\u003e \n\u003cp\u003eOne optimal strategy is as follows:\u003c/p\u003e \n\u003cul\u003e \n \u003cli\u003e \u003cp\u003eIn the first operation, choose the first, second and third elements. The sequence A becomes (1, 1, 1, 4).\u003c/p\u003e \u003c/li\u003e \n \u003cli\u003e \u003cp\u003eIn the second operation, choose the second, third and fourth elements. The sequence A becomes (1, 1, 1, 1).\u003c/p\u003e \u003c/li\u003e \n\u003c/ul\u003e"}},{"title":"Sample Input 2","value":{"format":"MD","content":"\u003ch3\u003e\u003c/h3\u003e\n\u003cpre\u003e3 3\n1 2 3\n\u003c/pre\u003e"}},{"title":"Sample Output 2","value":{"format":"MD","content":"\u003ch3\u003e\u003c/h3\u003e\n\u003cpre\u003e1\n\u003c/pre\u003e"}},{"title":"Sample Input 3","value":{"format":"MD","content":"\u003ch3\u003e\u003c/h3\u003e\n\u003cpre\u003e8 3\n7 3 1 8 4 6 2 5\n\u003c/pre\u003e"}},{"title":"Sample Output 3","value":{"format":"MD","content":"\u003ch3\u003e\u003c/h3\u003e\n\u003cpre\u003e4\n\u003c/pre\u003e"}}]}