标签:style blog http color java os io for
5 0 0 1 1 1 1 1 5 0 3 1 2 3 4 5
5 4
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cstdlib> 5 #include <vector> 6 #include <climits> 7 #include <algorithm> 8 #include <cmath> 9 #define LL long long 10 #define INF 0x3f3f3f3f 11 using namespace std; 12 const int maxn = 100100; 13 int qa[maxn],qb[maxn],h1,h2,t1,t2; 14 int n,m,k,d[maxn],lst1,lst2; 15 int main(){ 16 int i,ans; 17 while(~scanf("%d %d %d",&n,&m,&k)){ 18 for(i = 1; i <= n; i++) 19 scanf("%d",d+i); 20 lst2 = lst1 = h1 = h2 = 0; 21 t1 = t2 = -1; 22 ans = 0; 23 for(i = 1; i <= n; i++){ 24 while(t1 >= h1 && d[qa[t1]] <= d[i]) t1--; 25 qa[++t1] = i; 26 while(t2 >= h2 && d[qb[t2]] >= d[i]) t2--; 27 qb[++t2] = i; 28 while(d[qa[h1]] - d[qb[h2]] > k){ 29 if(qa[h1] < qb[h2]){ 30 lst1 = qa[h1++]; 31 }else lst2 = qb[h2++]; 32 } 33 if(d[qa[h1]] - d[qb[h2]] >= m) 34 ans = max(ans,i-max(lst1,lst2)); 35 } 36 printf("%d\n",ans); 37 } 38 return 0; 39 } 40 /* 41 5 0 0 42 1 1 1 1 1 43 5 0 3 44 1 2 3 4 5 45 */
xtu summer individual 5 D - Subsequence,布布扣,bubuko.com
xtu summer individual 5 D - Subsequence
标签:style blog http color java os io for
原文地址:http://www.cnblogs.com/crackpotisback/p/3895911.html