二分查找
#include
int a[10000];
int ans;
void search(int m,int n,int l,int k)
{
if(m>n)
return ;
else
{
int sum=0,mid=(m+n)/2;
for(int i=0;i
sum+=a[i]/mid;
if(sum>=k)
{
ans=mid;
search(mid+1,n,l,k);
}
else
search(m,mid-1,l,k);
}
}
int main()
{
int n,k;
while(scanf("%d %d",&n,&k)!=EOF)
{
int max=0;
float s;
for(int i=0;i
{
scanf("%f",&s);
a[i]=s*100;
if(a[i]>max)
max=a[i];
}
search(1,max,n,k);
if(ans<1)
printf("0.00\n");
else
printf("%.2f",0.01*ans);
}
return 1;
}