单调队列(数组优化?)P1886
作者:互联网
class Deque{
public:
int a[maxn];
int pl=1,pr=0;
}Deq;
int a[maxn];
int n,k;
void solve(){
Deq.pl=1;Deq.pr=0;
for(int i=1;i<=n;i++){
while(Deq.pr>=Deq.pl&&a[Deq.a[Deq.pr]]<a[i])Deq.pr--;//弹尾
Deq.a[++Deq.pr]=i;//入尾
if(Deq.a[Deq.pl]+k<=i)Deq.pl++;//弹首
o(a[Deq.a[Deq.pl]]);putchar(' ');
}
putchar('\n');
}
标签:pr,putchar,P1886,Deq,队列,int,maxn,pl,单调 来源: https://www.cnblogs.com/yesuweiYYYY/p/13841169.html