1 solutions
-
0
虎鲸der题解
用二分做 这题主包调了半天,如果你的L不是1,建议改成1,如果你有主包题解里的ans,一定要是0。:(
#include<bits/stdc++.h> using namespace std; int n,k; const int M=1e5+2; int a[M]; int check(long long m){ int s=0; for(int i=1;i<=n;i++){ s+=a[i]/m; } if(s>=k) return 1; return 0; } int main(){ cin>>n>>k; int t=0; for(int i=1;i<=n;i++){ cin>>a[i]; t=max(t,a[i]); } int l=1,r=t; int ans=0; while(l<=r){ int m=(l+r)/2; if(check(m)){ l=m+1; ans=m; } else{ r=m-1; } } cout<<ans; return 0; }嘻嘻
Information
- ID
- 27
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 5
- Tags
- # Submissions
- 2
- Accepted
- 1
- Uploaded By