Language: C++

#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;
bool is_possible(int64_t target, const int64_t k, const vector<int> a, const vector<int> f) {
    const int n = a.size();
    int64_t cost = 0;
    rep(i, n) {
        int64_t need = target / f[i];
        cost += max(0LL, a[i] - need);
    }
    return cost <= k;

}
int main() {
    int n; uint64_t k; cin >> n >> k;
    vector<int> a(n);
    for (auto &v: a) cin >> v;
    vector<int> f(n);
    for (auto &v: f) cin >> v;

    sort(a.begin(), a.end(), greater<>());
    sort(f.begin(), f.end());

    int64_t left = 0, right = 1e18;
    while (abs(left - right) > 1) {
        int64_t mid = (left + right) / 2;
        if (is_possible(mid, k, a, f)) {
            right = mid;
        } else {
            left = mid;
        }
    }
    cout << right << endl;
    return 0;
}


Compiler output:
a.cc: In function 'bool is_possible(int64_t, int64_t, std::vector<int>, std::vector<int>)':
a.cc:27:20: error: no matching function for call to 'max(long long int, int64_t)'
   27 |         cost += max(0LL, a[i] - need);
      |                 ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/specfun.h:43,
                 from /usr/include/c++/14/cmath:3906,
                 from a.cc:2:
/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:27:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int64_t' {aka 'long int'})
   27 |         cost += max(0LL, a[i] - need);
      |                 ~~~^~~~~~~~~~~~~~~~~~
/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,
                 from a.cc:6:
/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:27:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   27 |         cost += max(0LL, a[i] - need);
      |                 ~~~^~~~~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:33:12: error: 'uint64_t' was not declared in this scope
   33 |     int n; uint64_t k; cin >> n >> k;
      |            ^~~~~~~~
a.cc:15:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
   14 | #include <iterator>
  +++ |+#include <cstdint>
   15 | #define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
a.cc:33:36: error: 'k' was not declared in this scope
   33 |     int n; uint64_t k; cin >> n >> k;
      |                                    ^