给定n根木头,第i根长度为a[i]。要切成不少于m段等长木段,求最大可能长度,请补全以下C++代码中的两处横线空缺:
const int MAXN = 100005;
long long a[MAXN];
int n, m;
bool check(long long x){
long long cnt = 0;
for(int i = 1; i <= n; i++){
if(x == 0) return true;
cnt += a[i] / x;
if(cnt >= m) return true;
}
return false;
}
int main(){
cin >> n >> m;
long long mx = 0;
for(int i = 1; i <= n; i++){
cin >> a[i];
mx = max(mx, a[i]);
}
long long l = 1, r = mx;
long long ans = 0;
while(l <= r){
long long mid = l + (r - l) / 2;
if(check(mid)){
ans = mid;
______________________
}else{
______________________
}
}
cout << ans << endl;
return 0;
}