提交时间:2024-08-21 01:03:19
运行 ID: 173684
#include<bits/stdc++.h> using namespace std; const int N=1e6+10; int n,a[N],q[N],h,t=-1,k; int main() { cin>>n>>k; for(int i=1;i<=n;++i) { scanf("%d",&a[i]); } for(int i=1;i<=n;++i) { while(h<=t && q[h]<=i-k)h++; while(h<=t && a[q[t]]<=a[i])t--; q[++t]=i; if(i-k>=0)printf("%d",a[q[h]]); } return 0; }