77分,求调
查看原帖
77分,求调
1483497
Cc24110906楼主2025/1/19 18:56
#include<bits/stdc++.h>
using namespace std; 
double n,k,a[100010],maxn,l,r,mid,ans;
long double sum;
bool check(double mid){
	double num=0.00;
	for(int i=1;i<=n;i++){
		num+=floor(a[i]/mid);
	}
	if(num>=k)
		return 1;
	else
		return 0;
}
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		a[i]*=100.00;
		maxn=max(maxn,a[i]);
		sum+=a[i];
	}
	if(sum<k*100.00){
		cout<<0.00;
		return 0;
	}
	l=100.00,r=maxn;
	while(l<=r){
		mid=l+(r-l)/2;
		if(check(mid)){
			ans=mid;
			l=mid+0.01;
		}
		else{
			r=mid-0.01;
		}
	}
	cout<<fixed<<setprecision(2)<<1.00*(ans/100.00);
	return 0;
}
2025/1/19 18:56
加载中...