Title Link: Http://codeforces.com/problemset/problem/548/D
Give you n number, for (1,n) length, let you find the maximum value of the minimum value of the line segment is how much
#include <iostream>#include<cstring>#include<cstdio>#include<queue>#include<algorithm>#defineN 200050#defineINF 1e16#defineMet (A, b) memset (A, B, sizeof (a))using namespaceStd;typedefLong LongLL;intA[n], ans[n], N, L[n], r[n];intMain () { while(SCANF ("%d", &n)! =EOF) {a[0]=-1, a[n+1]=-1; for(intI=1; i<=n; i++) scanf ("%d", &A[i]); for(intI=1; i<=n; i++)///The left margin with a[i] as the minimum value; { intj = I1; while(A[j]>=a[i]) j=L[j]; L[i]=J; } for(intJ=m; i>=1; i--)///The right boundary with A[i] as the minimum value; { intj=i+1; while(A[j]>=a[i]) j=S[j]; R[i]=J; } for(intI=1; i<=n; i++) { intlen=r[i]-l[i]-1; Ans[len]=max (Ans[len], a[i]);///Ans[len] Indicates the minimum value of Len, and the current a[i]; } for(inti=n-1; i>=1; i--)///update the values that are not updated;Ans[i]=max (Ans[i], ans[i+1]); for(intI=1; i<=n; i++) printf ("%d%c", Ans[i], i==n?'\ n':' '); } return 0;}View Code
D. Mike and Feet---cf548d (max.)