#Q177. 「一本通 5.5 例 1」滑动窗口
「一本通 5.5 例 1」滑动窗口
Description
Original Source: POJ 2823
Given an array of length , a sliding window of size moves from the far left to the far right. You can only see the numbers in the window at any time. Each time the window moves one position to the right, as shown below:
| Window Position | Minimum | Maximum |
|---|---|---|
Your task is to determine the maximum and minimum values in the sliding window at every position.
Input Format
Line 1: Two integers and ;
Line 2: integers representing the elements of the array ();
Output Format
The first line contains the minimum values as the sliding window moves from left to right, with each number separated by a space;
The second line contains the maximum values as the sliding window moves from left to right, with each number separated by a space.
Sample 1
8 3
1 3 -1 -3 5 3 6 7
-1 -3 -3 -3 3 3
3 3 5 5 6 7
Constraints & Hints
For of the data, ;
For of the data, ;
For of the data, .