#include <bits/stdc++.h>
using namespace std;
long long n,k,X;
struct wbx{
long long N,x;
};
deque<wbx>A;
int main()
{
cin>>n>>k;
for(int i=1;i<=n;i++)
{
cin>>X;
while(A.back().x>=X)
{
A.pop_back();
if(A.size()==0) break;
}
A.push_back({i,X});
while(A.front().N<=i-k) A.pop_front();
cout<<A.front().x<<" ";
}
return 0;
}
这题:
8 3
1 3 -1 -3 5 3 6 7
运行时错误,怎么改才不会运行错误?