{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\n \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n An array of size \n \u003ci\u003en\u003c/i\u003e ≤ 10\n \u003csup\u003e6\u003c/sup\u003e is given to you. There is a sliding window of size \n \u003ci\u003ek\u003c/i\u003e which is moving from the very left of the array to the very right. You can only see the \n \u003ci\u003ek\u003c/i\u003e numbers in the window. Each time the sliding window moves rightwards by one position. Following is an example: \n \u003cbr\u003eThe array is \n \u003cfont face\u003d\"Courier New,Courier,monospace\" size\u003d\"2\"\u003e[1\u0026nbsp;3\u0026nbsp;-1\u0026nbsp;-3\u0026nbsp;5\u0026nbsp;3\u0026nbsp;6\u0026nbsp;7]\u003c/font\u003e, and \n \u003ci\u003ek\u003c/i\u003e is 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"}}]}