HZY44561939 @ 2024-11-14 22:16:10
#include<bits/stdc++.h>
using namespace std;
int n,k,a[2000010];
deque<int> q;
int main()
{
cin>>n>>k;
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
for(int i = 0;i < n;i++)
{
if(i==0)
{
cout<<0<<endl;
continue;
}
while(!q.empty() && a[i]<a[q.back()])
{
q.pop_back();
}
q.push_back(i);
while(i-k>=q.front()&&!q.empty())
{
q.pop_front();
}
cout<<a[q.front()]<<endl;
}
return 0;
}
by pbcoding @ 2024-11-14 22:17:33
@HZY44561939 用scanf()printf()
by HZY44561939 @ 2024-11-14 22:45:01
@pbcoding 学学啦!已AC