给定 n 根木头,第 i 根长度为 a[i]。要切成不少于 m 段等长木段,求最大可能长度,则横线上应填
写( )。
const int MAXN = 100005; long long a[MAXN]; int n, m; bool check(long long x){ long long cnt = 0; for(int i = 1; i <= n; i++){ if(x == 0) return true; cnt += a[i] / x; if(cnt >= m) return true; } return false; } int main(){ cin >> n >> m; long long mx = 0; for(int i = 1; i <= n; i++){ cin >> a[i]; mx = max(mx, a[i]); } long long l = 1, r = mx; long long ans = 0; while(l <= r){ long long mid = l + (r - l) / 2; if(check(mid)){ ans = mid; ______________________ }else{ ______________________ } } cout << ans << endl; return 0; }