Language: C++

#include<bits/stdc++.h>
using namespace std;
//using p=pair<int,int>;
//typedef ll  long long
//#define rep(i,N) for(int i=0;i<N;i++)

 int main(){

  long long n,k;
  cin>>n>>k;
   vector<long long>a(n),f(n);

    for(int i=0;i<n;i++)
    cin>>a[i];
    for(int i=0;i<n;i++)
    cin>>f[i];

    sort(a.begin(),a.end());
    sort(f.rbegin(),f.end());

    int low=0,high= 1e18;

    while(low<high){

     long mid = (low+high)/2;
     long long cnt=0;
     for(int i=0;i<k;i++){

        if(mid < a[i]*f[i])
            cnt += a[i]-mid/f[i];
     }

     if(cnt<= k)
        high = mid;
     else
        low = mid+1;
    }

    cout<<low<<endl;

 return 0;
 }


Compiler output:
a.cc: In function 'int main()':
a.cc:19:9: error: no matching function for call to 'sort(std::vector<long long int>::reverse_iterator, std::vector<long long int>::iterator)'
   19 |     sort(f.rbegin(),f.end());
      |     ~~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate: 'template<class _RAIter> void std::sort(_RAIter, _RAIter)'
 4762 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4762:5: note:   template argument deduction/substitution failed:
a.cc:19:9: note:   deduced conflicting types for parameter '_RAIter' ('std::reverse_iterator<__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> > >' and '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >')
   19 |     sort(f.rbegin(),f.end());
      |     ~~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note: candidate: 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)'
 4793 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)'
  292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note:   candidate expects 4 arguments, 2 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)'
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note:   candidate expects 3 arguments, 2 provided
a.cc:21:21: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   21 |     int low=0,high= 1e18;
      |                     ^~~~