1362 simple version of window fetch

Source: Internet
Author: User
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] 
     

      

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.