Chizuru_Ichinose @ 2023-10-17 19:38:24
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int kMax=2e6+5;
int n,k,a[kMax],t=1;
deque<int> q;
signed main() {
scanf("%lld%lld",&n,&k);
for(int i=1; i<=n; i++) scanf("%lld",&a[i]);
cout<<0<<endl;
for(int i=1; i<n; i++) {
while(!q.empty() && a[i]<=q.back()) q.pop_back();
q.push_back(a[i]);
if(i-t>=k && q.front()==a[t]) {
t++;
q.pop_front();
}
if(i-t>=k && q.front()!=a[t]) t++;
printf("%lld\n",q.front());
}
return 0;
}
by JOKER_chu @ 2023-12-21 13:25:41
@Lontano_Island 12行的<=换成<
by Chizuru_Ichinose @ 2024-02-29 20:44:00
@chuxm 感谢