66666以红温66666
2024-10-21 22:02:17
发布于:广东
3阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
double arr[300005];
int n,k;
bool jug(double mid)
{
double mi = 0 ;
for(int i = k ; i <= n ; i ++ )
{
if(arr[i] - i * mid > mi)return true;
mi = min(mi,arr[i - k + 1] - (i - k + 1) * mid);
}
return false;
}
int main()
{
cin >> n >> k ;
for(int i = 1 ; i <= n ; i ++)
{
cin >> arr[i];
arr[i] += arr[i-1];
}
double l = 0 ;
double r = 1e6+10;
while(r - l >= 0.0001)
{
// cout << r << " " << l << endl;
double mid = (r + l) / 2;
if(jug(mid)){
l = mid;
}else{
r = mid;
}
}
printf("%.4lf",l);
return 0;
}
这里空空如也
有帮助,赞一个