{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\n \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n 给您一个大小n≤1e6的数组。有一个K大小的滑动窗口,它从数组的最左边移动到最右边。您只能在窗口中看到K数字。每次滑动窗口向右移动一个位置。以下是一个例子:\n数组是[1 3-1-3 5 3 6 7],k是3。\n \u003ctable frame\u003d\"BOX\" rules\u003d\"ALL\"\u003e\n \u003ctbody\u003e\n \u003ctr align\u003d\"CENTER\"\u003e\n \u003cth\u003eWindow position\u003c/th\u003e\n \u003cth\u003eMinimum value\u003c/th\u003e\n \u003cth\u003eMaximum value\u003c/th\u003e\n \u003c/tr\u003e\n \u003ctr class\u003e\n \u003ctd\u003e\u003cfont face\u003d\"Courier New,Courier,monospace\" size\u003d\"2\"\u003e[1\u0026nbsp;\u0026nbsp;3\u0026nbsp;\u0026nbsp;-1]\u0026nbsp;-3\u0026nbsp;\u0026nbsp;5\u0026nbsp;\u0026nbsp;3\u0026nbsp;\u0026nbsp;6\u0026nbsp;\u0026nbsp;7\u0026nbsp;\u003c/font\u003e\u003c/td\u003e\n \u003ctd align\u003d\"RIGHT\"\u003e\u003cfont face\u003d\"Courier New,Courier,monospace\" size\u003d\"2\"\u003e-1\u003c/font\u003e\u003c/td\u003e\n \u003ctd align\u003d\"RIGHT\"\u003e\u003cfont face\u003d\"Courier New,Courier,monospace\" size\u003d\"2\"\u003e3\u003c/font\u003e\u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr class\u003e\n \u003ctd\u003e\u003cfont face\u003d\"Courier New,Courier,monospace\" size\u003d\"2\"\u003e\u0026nbsp;1\u0026nbsp;[3\u0026nbsp;\u0026nbsp;-1\u0026nbsp;\u0026nbsp;-3]\u0026nbsp;5\u0026nbsp;\u0026nbsp;3\u0026nbsp;\u0026nbsp;6\u0026nbsp;\u0026nbsp;7\u0026nbsp;\u003c/font\u003e\u003c/td\u003e\n \u003ctd align\u003d\"RIGHT\"\u003e\u003cfont face\u003d\"Courier New,Courier,monospace\" size\u003d\"2\"\u003e-3\u003c/font\u003e\u003c/td\u003e\n \u003ctd align\u003d\"RIGHT\"\u003e\u003cfont face\u003d\"Courier New,Courier,monospace\" size\u003d\"2\"\u003e3\u003c/font\u003e\u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr class\u003e\n \u003ctd\u003e\u003cfont face\u003d\"Courier New,Courier,monospace\" size\u003d\"2\"\u003e\u0026nbsp;1\u0026nbsp;\u0026nbsp;3\u0026nbsp;[-1\u0026nbsp;\u0026nbsp;-3\u0026nbsp;\u0026nbsp;5]\u0026nbsp;3\u0026nbsp;\u0026nbsp;6\u0026nbsp;\u0026nbsp;7\u0026nbsp;\u003c/font\u003e\u003c/td\u003e\n \u003ctd align\u003d\"RIGHT\"\u003e\u003cfont face\u003d\"Courier New,Courier,monospace\" size\u003d\"2\"\u003e-3\u003c/font\u003e\u003c/td\u003e\n \u003ctd align\u003d\"RIGHT\"\u003e\u003cfont face\u003d\"Courier New,Courier,monospace\" size\u003d\"2\"\u003e5\u003c/font\u003e\u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr class\u003e\n \u003ctd\u003e\u003cfont face\u003d\"Courier New,Courier,monospace\" size\u003d\"2\"\u003e\u0026nbsp;1\u0026nbsp;\u0026nbsp;3\u0026nbsp;\u0026nbsp;-1\u0026nbsp;[-3\u0026nbsp;\u0026nbsp;5\u0026nbsp;\u0026nbsp;3]\u0026nbsp;6\u0026nbsp;\u0026nbsp;7\u0026nbsp;\u003c/font\u003e\u003c/td\u003e\n \u003ctd align\u003d\"RIGHT\"\u003e\u003cfont face\u003d\"Courier New,Courier,monospace\" size\u003d\"2\"\u003e-3\u003c/font\u003e\u003c/td\u003e\n \u003ctd align\u003d\"RIGHT\"\u003e\u003cfont face\u003d\"Courier New,Courier,monospace\" size\u003d\"2\"\u003e5\u003c/font\u003e\u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr class\u003e\n \u003ctd\u003e\u003cfont face\u003d\"Courier New,Courier,monospace\" size\u003d\"2\"\u003e\u0026nbsp;1\u0026nbsp;\u0026nbsp;3\u0026nbsp;\u0026nbsp;-1\u0026nbsp;\u0026nbsp;-3\u0026nbsp;[5\u0026nbsp;\u0026nbsp;3\u0026nbsp;\u0026nbsp;6]\u0026nbsp;7\u0026nbsp;\u003c/font\u003e\u003c/td\u003e\n \u003ctd align\u003d\"RIGHT\"\u003e\u003cfont face\u003d\"Courier New,Courier,monospace\" size\u003d\"2\"\u003e3\u003c/font\u003e\u003c/td\u003e\n \u003ctd align\u003d\"RIGHT\"\u003e\u003cfont face\u003d\"Courier New,Courier,monospace\" size\u003d\"2\"\u003e6\u003c/font\u003e\u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr class\u003e\n \u003ctd\u003e\u003cfont face\u003d\"Courier New,Courier,monospace\" size\u003d\"2\"\u003e\u0026nbsp;1\u0026nbsp;\u0026nbsp;3\u0026nbsp;\u0026nbsp;-1\u0026nbsp;\u0026nbsp;-3\u0026nbsp;\u0026nbsp;5\u0026nbsp;[3\u0026nbsp;\u0026nbsp;6\u0026nbsp;\u0026nbsp;7]\u003c/font\u003e\u003c/td\u003e\n \u003ctd align\u003d\"RIGHT\"\u003e\u003cfont face\u003d\"Courier New,Courier,monospace\" size\u003d\"2\"\u003e3\u003c/font\u003e\u003c/td\u003e\n \u003ctd align\u003d\"RIGHT\"\u003e\u003cfont face\u003d\"Courier New,Courier,monospace\" size\u003d\"2\"\u003e7\u003c/font\u003e\u003c/td\u003e\n \u003c/tr\u003e\n \u003c/tbody\u003e\n \u003c/table\u003e\n \u003cp\u003eYour task is to determine the maximum and minimum values in the sliding window at each position. \u003cbr\u003e\u003c/p\u003e\n \u003c/div\u003e\n 给定一个序列,对于所有的i\u003e\u003dk,输出序列中[i-k+1,i]内的最大值和最小值。"}},{"title":"Input","value":{"format":"HTML","content":"\n \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n The input consists of two lines. The first line contains two integers \n \u003ci\u003en\u003c/i\u003e and \n \u003ci\u003ek\u003c/i\u003e which are the lengths of the array and the sliding window. There are \n \u003ci\u003en\u003c/i\u003e integers in the second line. \n \u003cbr\u003e\n \u003c/div\u003e\n第一行两个整数n和k\u003c/br\u003e\n第二行n个整数,表示序列。"}},{"title":"Output","value":{"format":"HTML","content":"\n \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n There are two lines in the output. The first line gives the minimum values in the window at each position, from left to right, respectively. The second line gives the maximum values. \n \u003cbr\u003e\n \u003c/div\u003e\n输出两个行,第一行表示最小值。第二行表示最大值。"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e8 3\n1 3 -1 -3 5 3 6 7\n\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e-1 -3 -3 -3 3 3\n3 3 5 5 6 7\n\u003c/pre\u003e"}},{"title":"Hint","value":{"format":"HTML","content":"不要使用bits/stdc++.h头文件\u003c/br\u003e\nvoid Rd(int \u0026res){\t\u003c/br\u003e\n\tchar c;int flag\u003d1;res\u003d0;\u003c/br\u003e\n\twhile(c\u003dgetchar(),c\u003c48){\u003c/br\u003e\n\t\tif(c\u003d\u003d\u0027-\u0027)flag\u003d-1;\u003c/br\u003e\n\t}\u003c/br\u003e\n\tdo res\u003d(res\u003c\u003c3)+(res\u003c\u003c1)+(c^48);\u003c/br\u003e\n\twhile(c\u003dgetchar(),c\u003e\u003d48);\t\u003c/br\u003e\n\tres*\u003dflag;\t\u003c/br\u003e\n}\u003c/br\u003e\nvoid Pdfs(int n){\u003c/br\u003e\n\tif(n\u003d\u003d0)return;\u003c/br\u003e\n\tPdfs(n/10);\u003c/br\u003e\n\tputchar(n%10^48);\u003c/br\u003e\n}\u003c/br\u003e\nvoid Print(int n){\u003c/br\u003e\n\tif(n\u003c0){putchar(\u0027-\u0027);n\u003d-n;}\u003c/br\u003e\n\tif(n\u003d\u003d0)putchar(\u00270\u0027);\u003c/br\u003e\n\telse Pdfs(n);\t\u003c/br\u003e\n}\u003c/br\u003e"}}]}