13223 - Maximum of Interval   

Description

 

Given a sequence a1, a2, ..., aN, and an positive integer L.

Let M(i) be the maximum among ai, ai+1, ..., ai+L-1.

For each i = 1, ..., N-L+1, please find the answer to M(i).

 

To prevent TLE, add the following code at the first line of your main function and don't use endl in your code.

ios::sync_with_stdio(0); cin.tie(0);

Input

 

The first line of the input contains two integers N L.

The second line contains N numbers a1, a2, ..., aN.

 

For i = 1, ..., N, |ai| <= 106.

L <= N.

  • For testcase 1 and 2, N <= 100.
  • For testcase 3 and 4, N <= 5000.
  • For testcase 5 and 6, N <= 1000000.

 

Output

 

Please output N-L+1 numbers as the answers.

Remember to add new line in the end.

 

Sample Input  Download

Sample Output  Download

Tags




Discuss