标签:os io for ar ios sp return include
#include<iostream>
using namespace std;
int n,k,a[10000];
int binsearch(int low,int high)
{
int i,len,s;
while(low<high)
{
len=(high+low)/2;
for(s=0,i=0;i<n;i++) s+=a[i]/len;
if(s>k) low=len+1;
else if(s<k) high=len-1;
else return len;
}
}
int main()
{ int i,m,len;
while(cin>>n>>k)
{ for(m=0,i=0;i<n;i++)
{ cin>>a[i];
if(a[i]>m) m=a[i];
}
len=binsearch(0,m);
if(len<1) cout<<0<<endl; else cout<<len+1<<endl;
}
return 0;
}
标签:os io for ar ios sp return include
原文地址:http://www.cnblogs.com/2014acm/p/3905729.html