Prepare


#include <bits/stdc++.h> #define memset(a,b) memset(a,b,sizeof a) #define eps 1e-6 using namespace std; int n; int m[11111]; double ans,sum1[11111],sum2[11111],mn1[11111],mn2[11111],a[11111]; inline bool check(double x) { memset(mn1,127); memset(mn2,127); for(int i=1;i<=n;i++) a[i]=m[i]-x; for(int i=1;i<=n;i++) sum1[i]=sum1[i-1]+a[i],mn1[i]=min(sum1[i],mn1[i-1]); for(int i=n;i;i--) sum2[i]=sum2[i+1]+a[i],mn2[i]=min(sum2[i],mn2[i+1]); for(int i=1;i<n-1;i++) if(mn1[i]+mn2[i+2]<=0) return 1; return 0; } int main() { scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",m+i); double l=1,r=10000; while(r-l>eps) { double mid=(l+r)/2; if(check(mid)) r=mid-eps,ans=mid; else l=mid+eps; } printf("%.3lf\n",ans); return 0; }
<div class="cnblogs-markdown">
{0}
</div>
// Custom styles.
// Updated at 2019.02.22 by ShawnZhou
.post {
	margin-top: 60px;
	margin-bottom: 60px;
	padding: 25px;
    -webkit-box-shadow: 0 0 5px rgb(255, 255, 255);
    -moz-box-shadow: 0 0 5px rgba(202, 203, 204, .5);
   
}

.site-meta {
    background: url(https://s2.ax1x.com/2019/02/16/kseaVI.jpg);
    background-size: 100% auto;
}


.post-block {
    background: rgba(247, 255, 254, 0.7);
}

.comments {
    background: rgba(247, 255, 254, 0.7);    
}

.footer {
    color: #00f145;
}

.posts-expand .post-meta {
    color: #4079ee;
}

.site-subtitle {
    color: #fff;
}

body { 
    @media (max-width: 1080px) {
      background-image: url(https://s2.ax1x.com/2019/02/16/ksekCT.jpg);
      background-attachment: fixed;
      background-repeat: no-repeat;
      background-size: 100% 100%; 
    }
    @media (min-width: 1080px) {
      background-image: url(https://s2.ax1x.com/2019/02/16/kseVv4.jpg);
      background-attachment: fixed;
      background-repeat: no-repeat;
      background-size: 100% 100%; 
    }
  
}

.header-inner {
    background: url(https://s2.ax1x.com/2019/02/16/kseeKJ.jpg);
    background-size: 100% 100%;
}

.sidebar-inner {
    background: #d0ed5a;
    background: url(https://s2.ax1x.com/2019/02/16/kseeKJ.jpg);
    background-size: 100% 100%;    
}

.menu-item-active a {
    background: #d0ed5a;
    border-bottom-color: #d0ed5a;
}

.site-description {
    color: #000;
}

.site-state-item-name {
    color: #0058ff;
}

.pagination {
    background: #d0ed5a;
}

.pagination .page-number.current {
    background: #00beff;
    border-top-color: #00beff;
}
posted @ 2019-05-25 22:08  Arthuer  阅读(172)  评论(0)    收藏  举报