Language: C++

#include <bits/stdc++.h>

using namespace std;

#define il inline
#define Rep(i, s, e) for (int i = s; i <= e; ++i)
#define Dep(i, s, e) for (int i = s; i >= e; --i)
#define file(a) freopen(#a".in", "r", stdin), freopen(#a".out", "w", stdout)

typedef long double db;

const db eps = 1e-8;

const int N = 200010;

il int read() {
    int x = 0; bool f = true; char c = getchar();
    while (!isdigit(c)) {if (c == '-') f = false; c = getchar();}
    while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
    return f ? x : -x;
}

int n, k, nmax;
int len[N];

bool check(db goal) {
    int cnt = 0;
    Rep(i, 1, n) cnt += max(ceil(len[i] / goal) - 1, 0);
    return cnt <= k;
}

int main() {
    n = read(), k = read();
    Rep(i, 1, n) len[i] = read(), nmax = max(nmax, len[i]);
    db l = 0, r = nmax;
    while (r - l > eps) {
        db mid = (l + r) / 2;
        if (!check(mid)) l = mid;
        else r = mid;
    }
    int x = floor(l);
    if (l + eps > 0.5 + x) cout << x + 1;
    else cout << x;
    return 0;
}

Compiler output:
a.cc: In function 'bool check(db)':
a.cc:28:28: error: no matching function for call to 'max(long double, int)'
   28 |     Rep(i, 1, n) cnt += max(ceil(len[i] / goal) - 1, 0);
      |                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:28:28: note:   deduced conflicting types for parameter 'const _Tp' ('long double' and 'int')
   28 |     Rep(i, 1, n) cnt += max(ceil(len[i] / goal) - 1, 0);
      |                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:28:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long double'
   28 |     Rep(i, 1, n) cnt += max(ceil(len[i] / goal) - 1, 0);
      |                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~