#include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #define N 1000 #define M 1000 using namespace std; int n,f; int a[N]; bool check(int x) { int s=0; for(int i=1;i<=n;i++) s+=a[i]/x; if(s>=f) return true; return false; } int main() { cin>>n>>f; f++; int sum=0; for(int i=1;i<=n;i++) { cin>>a[i]; sum+=a[i]; } int l=0,r=sum/f; while(l<r) { int mid=(l+r+1)/2; if(check(mid)) l=mid; else r=mid-1; } cout<<l<<endl; }
来源:https://www.cnblogs.com/liusu123456/p/12210148.html