D. Mike and Feet---cf548d (max.)

Source: Internet
Author: User

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.)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.