关于单调队列
  • 板块灌水区
  • 楼主Reset_vod
  • 当前回复2
  • 已保存回复2
  • 发布时间2023/6/6 21:58
  • 上次更新2023/10/23 13:47:45
查看原帖
关于单调队列
1006165
Reset_vod楼主2023/6/6 21:58
#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

运行时错误,怎么改才不会运行错误?

2023/6/6 21:58
加载中...