【题解】
直接二分答案即可。
1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 #define LL long long 5 #define rg register 6 #define N 200010 7 using namespace std; 8 LL n,m,l,r,mid,a[N]; 9 inline LL read(){ 10 LL k=0,f=1; char c=getchar(); 11 while(c<'0'||c>'9')c=='-'&&(f=-1),c=getchar(); 12 while('0'<=c&&c<='9')k=k*10+c-'0',c=getchar(); 13 return k*f; 14 } 15 inline bool check(){ 16 LL sum=0; 17 for(rg int i=1;i<=n;i++){ 18 sum+=a[i]/mid; 19 if(sum>=m) return 1; 20 } 21 return 0; 22 } 23 int main(){ 24 n=read(); m=read(); 25 for(rg int i=1;i<=n;i++) a[i]=read(),r+=a[i]; 26 while(l+1<r){ 27 mid=(l+r)>>1; 28 if(check()) l=mid; 29 else r=mid; 30 } 31 printf("%lld",l); 32 return 0; 33 }