{"trustable":false,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\nIbrahim教授为他的算法课程准备了最后的作业。他让他的学生实施了海报化图像滤镜。\n\n他们的算法将在整数数组上进行测试,其中第i个整数表示图像中第i个像素的颜色。图像是黑白的,因此每个像素的颜色将是0到255(含)之间的整数。\n\n要实现过滤器,学生需要将黑白颜色范围[0,255]分成连续颜色组,并选择每组中的一种颜色作为组的键。为了保留图像细节,组的大小不能大于k,并且每种颜色应该只属于一个组。\n\n最后,学生将使用该颜色指定的组键替换阵列中每个像素的颜色。\n\n为了更好地理解这种效果,这里是一个晒太阳龟的图像,其中应用了海报化过滤器,向右增加了k。\n为了使检查最终答案的过程更加容易,Ibrahim教授希望学生分组,并以产生字典最小可能阵列的方式分配键。"}},{"title":"Input","value":{"format":"HTML","content":"\n第一行输入包含两个整数n和k(1≤n≤10^5,1≤k≤256),图像中的像素数和一组的最大大小。\n\n第二行包含n个整数p1,p2,...,pn(0≤pi≤255),其中pi是第i个像素的颜色。"}},{"title":"Output","value":{"format":"HTML","content":"\n打印n个以空格分隔的整数;应用Posterization过滤器后表示图像的按字典顺序排列的最小可能数组。"}},{"title":"Examples","value":{"format":"HTML","content":"\u003cdiv class\u003d\"sample-test\"\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e4 3\u003cbr\u003e2 14 3 4\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003e0 12 3 3\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e5 2\u003cbr\u003e0 2 1 255 254\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003e0 1 1 254 254\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n\u003c/div\u003e"}},{"title":"Note","value":{"format":"HTML","content":"\n一种可能的方法来为第一个样本分组颜色和分配键:\n\n颜色2属于组[0,2],组密钥为0。\n\n颜色14属于组[12,14],组密钥12。\n\n颜色3和4属于组[3,5],组密钥3。\n\n其他组不会影响结果,因此这里没有列出。"}}]}