Language: C++

#include <bits/stdc++.h>
#define int long long

using namespace std;

int x=0,y=0,a=0,b=0,c=0;
int p[100001];
int q[100001];
int r[100001];
int res=0;
multiset<int> Set1, Set2;

signed main()
{
	scanf("%lld%lld%lld%lld%lld", &x, &y, &a, &b, &c);
	for (int i=0; i<a; i++)
		scanf("%lld", &p[i]);
	for (int i=0; i<b; i++)
		scanf("%lld", &q[i]);
	for (int i=0; i<c; i++)
		scanf("%lld", &r[i]);
	sort(r, r+c);
	reverse(r, r+c);
	for (int i=0; i<a; i++)
	{
		Set1.insert(p[i]);
	}
	for (int i=0; i<b; i++)
		Set2.insert(q[i]);
	while (Set1.size()>x)
		Set1.erase(Set1.begin());
	while (Set2.size()>y)
		Set2.erase(Set2.begin());
	for (auto ss : Set1)
		res+=ss;
	for (auto ss : Set2)
		res+=ss;
	for (int i=0; i<c; i++)	
	{
		int m1 = (*Set1.begin());
		int m2 = (*Set2.begin());
		if (m1<m2)
		{
			Set1.insert(r[i]);
			res+=max(0, r[i]-(*Set1.begin()));
			Set1.erase(Set1.begin());
		}
		else
		{
			Set2.insert(r[i]);
			res+=max(0, r[i]-(*Set2.begin()));
			Set2.erase(Set2.begin());
		}
	}	
	cout << res;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:45:33: error: no matching function for call to 'max(int, long long int)'
   45 |                         res+=max(0, r[i]-(*Set1.begin()));
      |                              ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
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:45:33: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   45 |                         res+=max(0, r[i]-(*Set1.begin()));
      |                              ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/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:45:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   45 |                         res+=max(0, r[i]-(*Set1.begin()));
      |                              ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:51:33: error: no matching function for call to 'max(int, long long int)'
   51 |                         res+=max(0, r[i]-(*Set2.begin()));
      |                              ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/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:51:33: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   51 |                         res+=max(0, r[i]-(*Set2.begin()));
      |                              ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/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
/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:51:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   51 |                         res+=max(0, r[i]-(*Set2.begin()));
      |                              ~~~^~~~~~~~~~~~~~~~~~~~~~~~~