1 条题解
-
0
C++ :
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll M=1e5+5; const ll inf=2e3; ll n,m; double a[M],b[M],L=inf,R,ans; int check(double x){ for(ll i=1;i<=n;++i) b[i]=b[i-1]+a[i]-x; double tmp=inf; for(ll i=m;i<=n;++i){ tmp=min(tmp,b[i-m]); if(b[i]-tmp>=0) return 1; } return 0; } void init(){ freopen("cowfnc.in","r",stdin); freopen("cowfnc.out","w",stdout); } int main(){ // init(); scanf("%lld%lld",&n,&m); for(ll i=1;i<=n;++i) scanf("%lf",&a[i]),L=min(L,a[i]),R=max(R,a[i]); while(L<=R-1e-4){ double mid=(L+R)/2; if(check(mid)) L=mid; else R=mid; } // printf("%.4lf\n",ans); ll tmp=R*1000; printf("%lld",tmp); return 0; }
- 1
信息
- ID
- 1054
- 时间
- 1000ms
- 内存
- 512MiB
- 难度
- 10
- 标签
- 递交数
- 2
- 已通过
- 2
- 上传者