AcWing 680. 剪绳子
原题链接
简单
作者:
Value
,
2021-03-02 09:51:54
,
所有人可见
,
阅读 304
#include <iostream>
#include <cstdio>
using namespace std;
const int N = 1E5 + 10;
typedef long long ll;
double a[N];
int n, m;
bool check(double x){
int k = 0;
for(int i = 0; i < n; i ++ ) k += int(a[i] / x);
return k >= m;
}
int main(){
cin >> n >> m;
for(int i = 0; i < n; i ++ ){
cin >> a[i];
}
double l = 0, r = 1e9;
while(r - l > 1e-4){
double mid = (l + r) / 2;
if(check(mid)) l = mid;
else r = mid;
}
printf("%.2lf", r);
return 0;
}