Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;
const double PI=3.14159265358979323846;


int main(){
  ll N,K,H,mx=0;
  cin>>N>>K;
  H=K;
  vector<ll> A;
  vector<ll> F;
  REP(i,N){
    ll a;
    cin>>a;
    A.push_back(a);
  }
  REP(i,N){
    ll a;
    cin>>a;
    F.push_back(a);
  }

  SORT(A);
  SORT(F);
  REVERSE(F);
  
  REP(i,N) mx=max(mx,A.at(i)*F.at(i));
  
  ll ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
  ll ok = mx; // 「index = N-1」が条件を満たさないこともあるので、初期値は N
  
  /* ok と ng のどちらが大きいかわからないことを考慮 */
  while (abs(ok - ng) > 1) {
      ll mid = (ok + ng) / 2;
      
      K=H;
    
      for(int i=0; i<N; ++i){
        if(max(0,A.at(i)-K)*F.at(i)>mid){
          K=0;
          break;
        }
        else{
          K-=A.at(i)-mid/F.at(i);
        }
      }
    
      if (K<0){
        ok = mid;
      }
    
      else ng = mid;
  }
  
  cout<<ok<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:56:15: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
   56 |         if(max(0,A.at(i)-K)*F.at(i)>mid){
      |            ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 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:56:15: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   56 |         if(max(0,A.at(i)-K)*F.at(i)>mid){
      |            ~~~^~~~~~~~~~~~~
/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:4:
/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:56:15: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   56 |         if(max(0,A.at(i)-K)*F.at(i)>mid){
      |            ~~~^~~~~~~~~~~~~