Language: C++

#include <bits/stdc++.h>
    using namespace std;
     
    int64_t divceil(int64_t numer, int64_t denom) {
        if (numer % denom == 0) {
            return numer / denom;
        } else {
            return 1L + numer / denom;
        }
    }
    int main() {
        int64_t N, K;
        cin >> N;
        cin >> K;
        int64_t max_a = -1;
     
        vector<int64_t> A(N);
        int64_t total_length = 0;
        for (uint64_t i = 0; i < N; i++) {
            cin >> A[i];
            total_length += A[i];
        }
     
        // 適当な初期値を与えて上界・下界とする
        double upper_bound = -1;
        double lower_bound = 10000000000;
        for (auto a : A) {
            int64_t split_num_heuristic = (K * a) / total_length;
            double val = 1.0 * a / (split_num_heuristic + 1);
            upper_bound = max(upper_bound, val);
            lower_bound = min(lower_bound, val);
        }
 
        int64_t result = upper_bound + 2;
        int64_t left = max(lower_bound, 1);
        int64_t right = upper_bound + 1;
        while (right >= left) {
            int64_t mid = (left + right) / 2;
     
            int64_t total_split = 0;
            for (uint64_t i = 0; i < N; i++) {
                int64_t split_num = divceil(A[i], mid) - 1L;
                total_split += split_num;
            }
     
            if (total_split <= K) {
                result = min(mid, result);
                right = mid - 1;
            } else {
                left = mid + 1;
            }
        }
        cout << result << endl;
    }

Compiler output:
a.cc: In function 'int main()':
a.cc:35:27: error: no matching function for call to 'max(double&, int)'
   35 |         int64_t left = max(lower_bound, 1);
      |                        ~~~^~~~~~~~~~~~~~~~
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:35:27: note:   deduced conflicting types for parameter 'const _Tp' ('double' and 'int')
   35 |         int64_t left = max(lower_bound, 1);
      |                        ~~~^~~~~~~~~~~~~~~~
/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:35:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'double'
   35 |         int64_t left = max(lower_bound, 1);
      |                        ~~~^~~~~~~~~~~~~~~~