{"trustable":false,"sections":[{"title":"题目描述","value":{"format":"MD","content":"**原题来自:[POJ 2823](http://poj.org/problem?id\u003d2823)**\n\n给一个长度为 $N$ 的数组,一个长为 $K$ 的滑动窗体从最左端移至最右端,你只能看到窗口中的 $K$ 个数,每次窗体向右移动一位,如下图:\n\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\n你的任务是找出窗体在各个位置时的最大值和最小值。\n\n\n"}},{"title":"输入格式","value":{"format":"MD","content":"第 1 行:两个整数 $N$ 和 $K$; \n第 2 行:$N$ 个整数,表示数组的 $N$ 个元素($元素大小≤2\\times 10^9$); \n"}},{"title":"输出格式","value":{"format":"MD","content":"第一行为滑动窗口从左向右移动到每个位置时的最小值,每个数之间用一个空格分开; \n第二行为滑动窗口从左向右移动到每个位置时的最大值,每个数之间用一个空格分开。\n"}},{"title":"样例","value":{"format":"MD","content":"\u003ctable class\u003d\u0027loj_sample\u0027\u003e\u003cthead\u003e \u003ctr\u003e \u003cth\u003eInput\u003c/th\u003e \u003cth\u003eOutput\u003c/th\u003e \u003c/tr\u003e\u003c/thead\u003e\u003ctbody\u003e \u003ctr\u003e \u003ctd\u003e\u003cpre\u003e8 3\n1 3 -1 -3 5 3 6 7\u003c/pre\u003e\u003c/td\u003e \u003ctd\u003e\u003cpre\u003e-1 -3 -3 -3 3 3\n3 3 5 5 6 7\u003c/pre\u003e\u003c/td\u003e \u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\n"}},{"title":"数据范围与提示","value":{"format":"MD","content":"对于 $20\\%$ 的数据,$K≤N≤1000$; \n对于 $50\\%$ 的数据,$K≤N≤10^5$; \n对于 $100\\%$ 的数据,$K≤N≤10^6$。\n"}}]}