Description
There is a string of integers waiting in the queue ......
There are n integers. You have a wooden box that can enclose M consecutive integers. Now you want to know that for any consecutive M integers in this queue, what are the largest and smallest integers?
Example:
1 2 3 2 1 m = 2
1 2 max 2 min 1
2 3 Max 3 min 2
3 2 max 3 min 2
2 1 Max 2 min 1
The output is two rows:
2 3 3 2
1 2 2 1
-
Input
-
The first line contains an integer T, indicating that there are T groups of test data;
The format of each group of test data is as follows:
The first line contains two integers, N. M indicates that N integers are in the queue and M integers are consecutive.
The second row contains N integers.
Where N is not greater than 1000, M is not greater than N.
-
Output
-
Output results according to the topic description format. The first act is Max, and the second act is Min.
-
Sample Input
-
1
-
5 2
-
1 2 3 2 1
-
Sample output
-
2 3 3 2
-
1 2 2 1
the window range is small, so it is simple. Abnormal users can view the window super edition.
# include
main () {int number, Te; int n, m; int I; int A [1000]; int B [1000]; int C [1000]; int Max, min; int up; Int J; scanf ("% d", & number); For (TE = 1; te <= number; Te ++) {up = 0; scanf ("% d", & N, & M); for (I = 0; I
MAX) {max = A [J]; continue ;} if (A [J]