/*二分答案即可*/
#include<bits/stdc++.h>
#define maxn 500005
#define ll long long
#define INF 5000005

using namespace std;

ll n,b,a[maxn];

int judge(ll x){
    ll tot=0;
    for(int i=1;i<=n;i++)
        tot+=a[i]/x+(a[i]%x!=0);
    if(tot<=b) return 1;
    else return 0;
}

int main(){
    while(scanf("%lld%lld",&n,&b),n>0){
        ll l=0,r=INF,mid,ans;
        for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
        while(l<=r){
            mid=l+r>>1;
            if(judge(mid))//要用的盒子小于b个 
                ans=mid,r=mid-1;
            else 
                l=mid+1;
        }
        printf("%lld\n",ans);
    }
    return 0;
} 

 

相关文章:

  • 2022-12-23
  • 2021-07-09
  • 2021-12-10
  • 2021-05-30
  • 2021-07-25
  • 2022-02-06
  • 2021-07-18
  • 2021-10-22
猜你喜欢
  • 2022-12-23
  • 2021-07-31
  • 2021-06-24
相关资源
相似解决方案