Language: C++

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	os << "{";
	rep(i, (int)v.size()) {
		if (i)
			os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
	for (auto val : array)
		std::cout << val << ", ";
	std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll n, k; std::cin >> n >> k;
	vector<ll> a(n); rep(i, n) std::cin >> a[i];
	vector<ll> f(n); rep(i, n) std::cin >> f[i];
	sort(rng(a)), sort(rng(f), greater<int>());
	priority_queue<pair<ll, ll>> time;
	rep(i, n) { time.emplace(a[i] * f[i], a[i]); }
	while (k > 0) {
		pair<ll, ll> ma = time.top(); time.pop();
		if (ma.fi == 0) break;
		pair<ll, ll> ne = time.top();
		ll diff = ma.fi - ne.fi;
		ll fi = ma.fi / ma.se;
		ll cnt = diff / fi + 1;
		chmin(cnt, k);
		k -= cnt;
		ma.se = max(ma.se - cnt, 0ll);
		ma.fi = fi * ma.se;
		time.push(ma);
	}
	pair<ll, ll> ma = time.top();
	std::cout << ma.fi << "\n";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:72:28: error: no matching function for call to 'max(long int, long long int)'
   72 |                 ma.se = max(ma.se - cnt, 0ll);
      |                         ~~~^~~~~~~~~~~~~~~~~~
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:72:28: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   72 |                 ma.se = max(ma.se - cnt, 0ll);
      |                         ~~~^~~~~~~~~~~~~~~~~~
/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:72:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   72 |                 ma.se = max(ma.se - cnt, 0ll);
      |                         ~~~^~~~~~~~~~~~~~~~~~