![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/83af3b73947ac5c0aa54849065b9ae00.png)
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
const int maxn = 10010;
double huoTui[maxn];
int n, m;
bool check(double mid)
{
int temp = 0;
for (int i = 0; i < n; i++)
{
temp += huoTui[i] / mid;
}
if (temp >= m)
{
return true;
}
else {
return false;
}
}
int main()
{
cin >> n >> m;
for (int i = 0; i < n; i++)
{
cin >> huoTui[i];
}
sort(huoTui, huoTui + n);
double l = huoTui[0];
double r = huoTui[n - 1];
while (l <= r)
{
if (r - l < 0.0000001)
{
break;
}
double mid = (l + r) / 2.0;
if (check(mid))
{
l = mid;
}
else {
r = mid;
}
}
int tmpmid = (int)(r*100);
double finmid = tmpmid/100.0;
printf("%.2lf",finmid);
}