Language: C++

#include <bits/stdc++.h>  
using namespace std;  
#define INF 0x3f3f3f3f  
typedef long long ll;  
const int N = 1e5 + 10;  
ll front[N], end[N];
int num[3*N];
int main()  
{  
   // freopen("in.txt", "r", stdin);
   	int n;
   	while (~scanf("%d", &n))
   	{
   		for (int i = 0; i < 3*n; i++)
   			scanf("%d", num + i);
   		priority_queue<int, vector<int>, greater<int> >qmin; 
   		priority_queue<int> qmax;
   		ll sum = 0;
   		qmin.push(num[0]);

   		for (int i = 0; i < n; i++)
   		{
   			sum += num[i];
   			qmin.push(num[i]);
   		}
   		int m = n<<1;
   		front[n-1] = sum;
   		for (int i = n; i < m; i++)
   		{
   			if (qmin.top() < num[i])
   			{
   				sum += num[i];
   				sum -= qmin.top();
   				qmin.pop();
   				qmin.push(num[i]);
   			}
   			front[i] = sum;
   		}

   		sum = 0;
   		for (int i = 3*n - 1; i >= m; i--)
   		{
   			sum += num[i];
   			qmax.push(num[i]);
   		}
   		end[m] = sum;
   		for (int i = m - 1; i >= n; i--)
   		{
   			if (num[i] < qmax.top())
   			{
   				sum += num[i];
   				sum -= qmax.top();
   				qmax.pop();
   				qmax.push(num[i]);
   			}	
   			end[i] = sum;
   		}
   		ll ans = front[n-1] - end[n];
   		for (int i = n; i < m; i++)
   		{
   			// if (n == 1)
   			// printf("%d %d\n", front[i-1], end[i]);
   			ans = max(front[i-1] - end[i], ans);
   		}
   		printf("%lld\n", ans);
   	}

   return 0;  
}  

Compiler output:
a.cc: In function 'int main()':
a.cc:46:17: error: reference to 'end' is ambiguous
   46 |                 end[m] = sum;
      |                 ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
                 from a.cc:1:
/usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/valarray:1249:5: note:                 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
 1249 |     end(valarray<_Tp>& __va) noexcept
      |     ^~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/range_access.h:106:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  106 |     end(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
   85 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
   74 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
In file included from /usr/include/c++/14/bits/algorithmfwd.h:39,
                 from /usr/include/c++/14/bits/stl_algo.h:59,
                 from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/initializer_list:99:5: note:                 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
   99 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
a.cc:6:14: note:                 'll end [100010]'
    6 | ll front[N], end[N];
      |              ^~~
a.cc:56:25: error: reference to 'end' is ambiguous
   56 |                         end[i] = sum;
      |                         ^~~
/usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/valarray:1249:5: note:                 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
 1249 |     end(valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  106 |     end(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
   85 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
   74 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/initializer_list:99:5: note:                 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
   99 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
a.cc:6:14: note:                 'll end [100010]'
    6 | ll front[N], end[N];
      |              ^~~
a.cc:58:39: error: reference to 'end' is ambiguous
   58 |                 ll ans = front[n-1] - end[n];
      |                                       ^~~
/usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/valarray:1249:5: note:                 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
 1249 |     end(valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  106 |     end(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
   85 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
   74 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/initializer_list:99:5: note:                 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
   99 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
a.cc:6:14: note:                 'll end [100010]'
    6 | ll front[N], end[N];
      |              ^~~
a.cc:63:48: error: reference to 'end' is ambiguous
   63 |                         ans = max(front[i-1] - end[i], ans);
      |                                                ^~~
/usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/valarray:1249:5: note:                 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
 1249 |     end(valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  106 |     end(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
   85 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
   74 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/initializer_list:99:5: note:                 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
   99 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
a.cc:6:14: note:                 'll end [100010]'
    6 | ll front[N], end[N];
      |              ^~~