标签:main 需要 code include txt inline har font for
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using namespace std; const int N=1e6+5; typedef long long ll; inline int read(){ char c=getchar();int x=0,f=1; while(c<‘0‘||c>‘9‘){if(c==‘-‘)f=-1;c=getchar();} while(c>=‘0‘&&c<=‘9‘){x=x*10+c-‘0‘;c=getchar();} return x*f; } int n,m,c,a[N],flag; int q1[N],h1,t1,q2[N],h2,t2; int main(){ //freopen("in.txt","r",stdin); n=read();m=read();c=read(); h1=h2=1;t1=t2=0; for(int i=1;i<=n;i++){ a[i]=read(); while(h1<=t1&&i-q1[h1]+1>m) h1++; while(h2<=t2&&i-q2[h2]+1>m) h2++; while(h1<=t1&&a[q1[t1]]<=a[i]) t1--; q1[++t1]=i; while(h2<=t2&&a[q2[t2]]>=a[i]) t2--; q2[++t2]=i; if(i-m+1>=1&&a[q1[h1]]-a[q2[h2]]<=c) printf("%d\n",i-m+1),flag=1; } if(!flag) puts("NONE"); }
BZOJ 1342: [Baltic2007]Sound静音问题 [单调队列]
标签:main 需要 code include txt inline har font for
原文地址:http://www.cnblogs.com/candy99/p/6284914.html