#include <stdio.h>int main () {puts ("reprint please specify source thank you");p UTS ("http://blog.csdn.net/vmurder/article/details/42971677 ");}
Test instructions
Although this problem is Chinese, I need to say a little bit about test instructions.
is to ask you the length of the interval of M, the maximum value of the interval-the minimum value <=c, the output of the left end of the interval.
Attention!!! If no scenario output is none.
Exercises
First we can write a multiset2400ms+, that is, and then seemingly can also write a line tree (do not know if anyone wrote)
But the positive solution is obviously to write a monotone queue of two O (n).
One maintains the current interval maximum and the other maintains the minimum value.
Code:
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define N 1001000# Define INF 0x3f3f3f3fusing namespace Std;int id1[n],x1[n],l1,r1;int id2[n],x2[n],l2,r2;int n,m,p,s[n];int main () { Freopen ("Test.in", "R", stdin), int i;scanf ("%d%d%d", &n,&m,&p), for (i=1;i<=n;i++) scanf ("%d", &s[i ]); L1=l2=1,r1=r2=0;int flag=1;for (i=1;i<=n;i++) {while (l1<=r1&&i-id1[l1]>=m) L1++;while (l2<= r2&&i-id2[l2]>=m) L2++;while (L1<=r1&&s[i]>=x1[r1]) r1--;while (L2<=r2&&s[i] <=X2[R2]) r2--;id1[++r1]=id2[++r2]=i;x1[r1]=x2[r2]=s[i];if (i>=m) if (x1[l1]-x2[l2]<=p) printf ("%d\n", i-m+ 1), flag=0;} if (flag) puts ("NONE"); return 0;}
"BZOJ1342" "Baltic2007" sound mute problem monotone queue