Language: C++

#include <bits/stdc++.h>
using namespace std;

struct ystruct {
    double val;
    int64_t init_length;
    int64_t split_num;
};
bool operator<=(const ystruct& lhs, const ystruct& rhs) {
    return lhs.val <= rhs.val;
}
bool operator<(const ystruct& lhs, const ystruct& rhs) {
    return lhs.val < rhs.val;
}
bool operator>=(const ystruct& lhs, const ystruct& rhs) {
    return lhs.val >= rhs.val;
}
bool operator>(const ystruct& lhs, const ystruct& rhs) {
    return lhs.val > rhs.val;
}
bool operator==(const ystruct& lhs, const ystruct& rhs) {
    return lhs.val == rhs.val;
}
bool operator!=(const ystruct& lhs, const ystruct& rhs) {
    return lhs.val != rhs.val;
}
ostream& operator<<(ostream& os, ystruct const& yst) {
    return os << yst.val;
}

int main() {
    int64_t N, K;
    cin >> N;
    cin >> K;

    int64_t total_length = 0;
    priority_queue<ystruct> yp;
    vector<int64_t> avec;
    for (uint64_t i = 0; i < N; i++) {
        int64_t A;
        cin >> A;
        yp.push(ystruct{val : 1.0 * A, init_length : A, split_num : 0});
        avec.push_back(A);
        total_length += A;
    }

    // 適当な初期値を与えて上界とする
    int64_t upper_bound = -1;
    for (auto a : avec) {
        int64_t split_num_heuristic = max(0, (K * a) / total_length - 1);
        upper_bound = max(upper_bound, a / (split_num_heuristic + 1));
    }

    uint64_t j = 0;
    while (j < K) {
        ystruct y = yp.top();
        yp.pop();
        ystruct ynew;

        ynew.split_num = y.split_num + 1;
        ynew.init_length = y.init_length;
        ynew.val = 1.0 * ynew.init_length / (ynew.split_num + 1);
        j++;

        while (ynew.val > upper_bound) {
            ynew.split_num = ynew.split_num + 1;
            ynew.val = 1.0 * ynew.init_length / (ynew.split_num + 1);
            j++;
        }

        yp.push(ynew);
    }
    ystruct yy = yp.top();
    if (yy.init_length % (yy.split_num + 1) == 0) {
        cout << (yy.init_length / (yy.split_num + 1)) << endl;
    } else {
        cout << (1 + yy.init_length / (yy.split_num + 1)) << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:50:42: error: no matching function for call to 'max(int, int64_t)'
   50 |         int64_t split_num_heuristic = max(0, (K * a) / total_length - 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:50:42: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'int64_t' {aka 'long int'})
   50 |         int64_t split_num_heuristic = max(0, (K * a) / total_length - 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:50:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   50 |         int64_t split_num_heuristic = max(0, (K * a) / total_length - 1);
      |                                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~