BZOJ 2096: [Poi2010]Pilots|单调队列
来源:互联网 发布:mac os x10.10.5下载 编辑:程序博客网 时间:2024/06/04 18:17
维护一个最大值的单调递减序列
维护一个最小值得单调递增序列
#include<set>#include<map>#include<ctime>#include<queue>#include<cmath>#include<cstdio>#include<vector>#include<cstring>#include<cstdlib>#include<iostream>#include<algorithm>#define T 3000006#define MX 1e9#define pa pair<int,int>using namespace std;priority_queue<pa,vector<pa>,greater<pa> >q;struct D{int x,pos;}mn[T],mx[T];int K,n,ans=0;int sc(){ int i=0,f=1; char c=getchar(); while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();} while(c>='0'&&c<='9')i=i*10+c-'0',c=getchar(); return i*f;}int main(){ int ln=1,rn=0,lx=1,rx=0,L=0; K=sc(),n=sc(); for(int i=1;i<=n;i++) { int x=sc(); while(rx>=lx&&mx[rx].x<=x)rx--; while(rn>=ln&&mn[rn].x>=x)rn--; mx[++rx]=mn[++rn]=(D){x,i}; while(mx[lx].x-mn[ln].x>K) { if(mx[lx].pos<mn[ln].pos)L=mx[lx].pos,lx++; else L=mn[ln].pos,ln++; } ans=max(ans,i-L); } cout<<ans; return 0;}
0 0
- BZOJ 2096([Poi2010]Pilots-单调队列-差值)
- BZOJ 2096 Poi2010 Pilots 单调队列
- BZOJ 2096: [Poi2010]Pilots|单调队列
- bzoj 2096: [Poi2010]Pilots 单调队列
- [BZOJ 2096][Poi2010]Pilots:单调队列
- 单调队列 BZOJ 2096 [Poi2010]Pilots
- BZOJ 2096: [Poi2010]Pilots 单调队列题解
- BZOJ 2096 [Poi2010]Pilots 单调队列
- bzoj 2096: [Poi2010]Pilots (二分答案+单调队列)
- 【BZOJ】【P2096】【Poi2010】【Pilots】【题解】【二分+单调队列】
- 【bzoj2096】[Poi2010]Pilots 单调队列
- BZOJ 2096: pilots 单调队列
- [BZOJ 2096]Poi2010 Pilots
- BZOJ 2096: [Poi2010]Pilots
- BZOJ 2096 [Poi2010]Pilots
- [BZOJ 2096][Poi2010]Pilots
- bzoj 2096: [Poi2010]Pilots
- 2096: [Poi2010]Pilots 单调队列维护最值
- PowerDesigner的Name和Code不同步设置
- saliency filters精读之permutohedral lattice
- KETTLE WEB管理控制台设计
- 一个类有多个基类的内存布局
- OSX: QuickLook快速预览不工作?
- BZOJ 2096: [Poi2010]Pilots|单调队列
- An Epoll example -- server and client
- JavaScript prototype 属性
- 门外汉怎么成就咨询大单(2)——北漂18年(40)
- SPAMS(稀疏和字典学习)工具箱的介绍、配置和使用
- Excel导入→JS拼出来的Table
- poj 2513 Colored Sticks 字典树+并查集+欧拉路
- 安卓Viewpager的使用--简单的欢迎页
- BZOJ 1342: [Baltic2007]Sound静音问题|单调队列