经典二分 (之前想错了 不过这两个地方应该可以加速)

#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll const maxn=2e5+5;
ll n,k,a[maxn],ans,maxl,l,r,mid;
bool check(ll m)
{
    ll ins=0;
    for(int i=1;i<=n;++i) ins+=(a[i]/m);
    return ins>=k;
}
int main()
{
  scanf("%lld%lld",&n,&k);
  for(int i=1;i<=n;++i)
  {
      scanf("%lld",&a[i]);
      maxl=max(maxl,a[i]);
  }
  l=1;r=maxl;
  if(!check(1)){cout<<0<<endl;return 0;}///切1都不满足
  if(check(maxl)){cout<<maxl<<endl;return 0;}///不切也满足
  while(l<=r)
  {
      mid=(l+r)>>1;
      if(check(mid)){ans=mid;l=mid+1;}
      else r=mid-1;
  }
  cout<<ans<<endl;
    return 0;
}