Pondo Minimum

View as PDF

Submit solution

Points: 100
Time limit: 5.0s
Memory limit: 977M

Author:
Problem type

Problem Statement

Pondo has an array of integers a of length n as well as an integer k. He wishes to form the array b of length n - k + 1 by taking taking all the subarrays of length k and taking their minimums, i.e. b_i = \min_{0\leq j \leq k-1}(a_{i+j}).

Input Format

Your first line will contain two space-separated integers n and k. Your next line will contain n integers representing a.

Output Format

You should output n - k + 1 integers representing b.

Constraints

  • 1 \leq n \leq 10^5
  • 1 \leq a_i \leq 10^9 ## Sample Cases
Input 1
10 5
10 9 8 7 6 5 4 3 2 1
Output 1
6 5 4 3 2 1
Input 2
10 4
684839257 302743967 551107459 232951579 483565957 241081121 553311714 547334166 25972405 997164454
Output 2
232951579 232951579 232951579 232951579 241081121 25972405 25972405

Comments

There are no comments at the moment.