题解
2023-05-27 17:23:57
发布于:上海
37阅读
0回复
0点赞
#include <iostream>
using namespace std;
int main(){
int n,k,a[100000], left,mid,num;
cin>>n>>k;
int right = 0;
for (int i = 0; i < n; i++){
cin>>a[i];
if (right < a[i]){
right = a[i];
}
}
right++;
left = 0 ;
while ( left + 1 < right) {
mid = (left + right) / 2;
num = 0;
for (int i = 0; i < n; i++){
if (num >= k){
break;
}
num = num + a[i] / mid ;
}
if ( num >= k ){
left = mid;
}else{
right = mid;
}
}
cout<<left<<endl;
return 0;
}
这里空空如也
有帮助,赞一个