标准题解
2023-12-30 14:45:38
发布于:浙江
82阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n,m;
int a[N];
bool check(int mid){
int num = 0;
for (int i = 0;i < n;i++){
num += a[i] / mid;
}
if (num >= m){
return true;
}
return false;
}
int main(){
cin>>n>>m;
int l = 0,r = 0 ;
for (int i = 0;i < n;i++){
cin>>a[i];
r = max(r,a[i]);
}
while(l < r){
int mid = l + r + 1 >> 1;
if (check(mid)) l = mid;
else r = mid - 1;
}
cout<<l;
return 0;
}
这里空空如也
有帮助,赞一个