#include<cstdio>
#include<algorithm>
#include<cstring>
#define N 1000005
using namespace std;
int q[N],a[N],n,m,l,r=-1;
int main()
{
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    q[++r]=1;
    for (int i=1;i<=n;i++)
    {
        while (q[l]<=i-m && r>=l) l++;
        while (a[q[r]]>a[i] && r>=l) r--;
        q[++r]=i;
        printf("%d\n",a[q[l]]);
    }
     return 0;
}
/*
5 2
2 4 1 5 7
8 3
2 0 0 2 0 6 2 1
8 1
2 0 0 1 0 7 0 3
*/

 

相关文章:

  • 2022-12-23
  • 2021-09-12
  • 2022-12-23
  • 2021-06-09
  • 2022-02-21
  • 2022-02-08
  • 2021-12-24
  • 2021-06-12
猜你喜欢
  • 2021-09-15
  • 2022-12-23
  • 2022-01-19
  • 2021-09-04
  • 2022-12-23
  • 2021-07-02
相关资源
相似解决方案