{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n div.illustration {\n float: right;\n padding-left: 20px;\n }\n div.illustration .illustration {\n width: 100%;\n border-radius: 4px;\n }\n pre {\n display: block;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n color: #333;\n word-break: break-all;\n word-wrap: break-word;\n }\n\u003c/style\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\[\u0027, right: \u0027\\\\]\u0027, display: true}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\n \u003cdiv style\u003d\"width:35.00%\" class\u003d\"illustration\"\u003e\n \u003cimg src\u003d\"CDN_BASE_URL/6b84377ad452d0a42dfa452edfa480fc?v\u003d1716192868\" alt\u003d\"/problems/smootharray/file/statement/en/img-0001.png\" class\u003d\"illustration\"\u003e\n\n \n \u003c/div\u003eWe always hope things in our lives will run smoothly, and\n having smooth arrays may help. An array \u003cspan class\u003d\"tex2jax_process\"\u003e$A$\u003c/span\u003e of \u003cspan class\u003d\"tex2jax_process\"\u003e$N$\u003c/span\u003e non-negative integers is\n \u003cspan class\u003d\"tex2jax_process\"\u003e$K_ S$\u003c/span\u003e-smooth if the sum\n of every set of \u003cspan class\u003d\"tex2jax_process\"\u003e$K$\u003c/span\u003e\n consecutive integers is exactly \u003cspan class\u003d\"tex2jax_process\"\u003e$S$\u003c/span\u003e. Unfortunately, not all arrays are\n \u003cspan class\u003d\"tex2jax_process\"\u003e$K_ S$\u003c/span\u003e-smooth. In fact,\n all \u003cspan class\u003d\"tex2jax_process\"\u003e$K_ S$\u003c/span\u003e-smooth arrays\n must contain a repeating pattern of length \u003cspan class\u003d\"tex2jax_process\"\u003e$K$\u003c/span\u003e. The image to the right shows an\n array of smoothies, and is totally unrelated to this problem,\n but may help you relax.\n\n \u003cp\u003eAny array can be made \u003cspan class\u003d\"tex2jax_process\"\u003e$K_\n S$\u003c/span\u003e-smooth by changing its elements. In each change one\n element may be modified to any integer between \u003cspan class\u003d\"tex2jax_process\"\u003e$0$\u003c/span\u003e and \u003cspan class\u003d\"tex2jax_process\"\u003e$S$\u003c/span\u003e, inclusive. You want to make all\n of your arrays smooth, but you don’t want to make any more\n changes than necessary. So the question is: What is the minimum\n number of changes you have to make so that a given array would\n become \u003cspan class\u003d\"tex2jax_process\"\u003e$K_ S$\u003c/span\u003e-smooth?\u003c/p\u003e\n\n \u003ch2\u003eInput\u003c/h2\u003e\n\n \u003cp\u003eThe first line of input will consist of three integers of\n the form:\u003c/p\u003e\u003cspan class\u003d\"tex2jax_process\"\u003e\\[ N\\; \\; K\\; \\; S\n \\]\u003c/span\u003e\n\n \u003cp\u003ewhere \u003cspan class\u003d\"tex2jax_process\"\u003e$N$\u003c/span\u003e is the size\n of the array, The remainder of the file will consist of\n \u003cspan class\u003d\"tex2jax_process\"\u003e$N$\u003c/span\u003e integers, \u003cspan class\u003d\"tex2jax_process\"\u003e$a_ n\\in A$\u003c/span\u003e, separated by white space.\n All input will be within the following\n constraints:\u003c/p\u003e\u003cspan class\u003d\"tex2jax_process\"\u003e\\[ 1 \\le K \\le N\n \\le 5000 \\]\u003c/span\u003e\u003cspan class\u003d\"tex2jax_process\"\u003e\\[ \\forall a_ n\n \\in A,\\; 0 \\le a_ n \\le S \\le 5000 \\]\u003c/span\u003e\n\n \u003ch2\u003eOutput\u003c/h2\u003e\n\n \u003cp\u003eYour program must output a single integer specifying the\n minimum number of changes that must be made in order to make\n the array \u003cspan class\u003d\"tex2jax_process\"\u003e$K_ S$\u003c/span\u003e\n smooth.\u003c/p\u003e\n\n \u003ch2\u003eSample 1\u003c/h2\u003e\u003cbody\u003e\u003ctable class\u003d\"vjudge_sample\"\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e3 3 5\n1\n2\n3\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/body\u003e\n\n \u003ch2\u003eSample 2\u003c/h2\u003e\u003cbody\u003e\u003ctable class\u003d\"vjudge_sample\"\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e6 3 5\n1\n2\n3\n3\n2\n1\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/body\u003e\n\n \u003ch2\u003eSample 3\u003c/h2\u003e\u003cbody\u003e\u003ctable class\u003d\"vjudge_sample\"\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e5 1 5\n1\n2\n3\n4\n5\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e4\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/body\u003e\n "}}]}