|
- #include<iostream>
- #include<algorithm>
- using namespace std;
- int n,k,a[100001],l,mid,r,ans,cnt;
- int main()
- {
- cin>>n>>k;
- for(int i=1;i<=n;i++)cin>>a[i];
- sort(a+1,a+n+1);
- r=a[n];
- while(l<=r)
- {
- mid=l+r>>1;
- if(!mid)break;
- cnt=0;
- for(int i=n;i>=1&&a[i]>=mid;--i)cnt+=a[i]/mid;
- if(cnt>=k)ans=mid,l=mid+1;
- else r=mid-1;
- }
- cout<<ans;
- return 0;
- }
复制代码 |
|