自己看
2026-08-20 16:34:21
发布于:广东
0阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,k;
ll a[100010];
bool func(ll mid){
ll ans=0;
for(ll i=1;i<=n;i++){
ans+=a[i]/mid;
}
return ans>=k;
}
int main(){
//freopen(".in",r,stdin);
//freopen(".out",w,stdout);
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
cin>>n>>k;
ll ma=-1e18;
for(ll i=1;i<=n;i++){
cin>>a[i];
ma=max(ma,a[i]);
}
ll l=1,r=ma;
while(l<=r){
ll mid=l+r>>1;
if(func(mid)){
l=mid+1;
}
else r=mid-1;
}
cout<<r<<endl;
//fclose(stdin);
//fclose(stdout);
return 0;
}
//coder::by::M91
这里空空如也






有帮助,赞一个