#include<iostream>
using namespace std;
int n, m, i,lbound, ubound, mid, count;
int len[10000]; // 钢材长度
int main() {
freopen("p1767.in","r",stdin);
freopen("p1767.out","w",stdout);
cin >> n>>m;
count = 0;
for (i = 0; i < n; i++) {
cin >> len[i];
count+=len[i] ;
}
if(count<m){
cout << "Failed" <<endl;
fclose(stdin);
fclose(stdout);
return 0;
}
lbound = 1;
ubound = 1000000;
while (lbound<ubound){
mid = (lbound+ubound+1)/2;
count = 0;
for (i = 0; i < n; i++)
count+=len[i]/mid;
if (count < m)
ubound = mid - 1;
else
lbound = mid;
}
cout << lbound << endl;
fclose(stdin);
fclose(stdout);
return 0;
}
( ) |