Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  ll a[3*N];
  for (int i = 0; i < 3*N; i++) {
    cin >> a[i];
  }
  priority_queue<ll, vector<ll>, greater<ll>> Q1;
  priority_queue<ll, vector<ll>, less<ll>> Q2;
  ll R1[N];
  ll R2[N];
  ll sum = 0;
  for (int i = 0; i < N; i++) {
    Q1.push(a[i]);
    Q2.push(a[(2*N)+i]);
    sum += a[i];
    sum -= a[(2*N)+i];
  }
  for (int i = 0; i < N; i++) {
    ll c = a[N+i] - Q1.top();
    c = max(0,c);
    Q1.pop();
    Q1.push(a[N+i]);
    if (i == 0) {
      R1[i] = c;
    } else {
      R1[i] = R1[i-1] + c;
    }
  }
  for (int i = N-1; i >= 0; i--) {
    ll b = Q2.top() - a[N+i];
    b = max(0,b);
    Q2.pop();
    Q2.push(a[N+i]);
    if (i == N-1) {
      R2[i] = b;
    } else {
      R2[i] = R2[i+1] + b;
    }
  }
  ll max_plus = -9999999999999;
  max_plus = max(max_plus,R1[N-1]);
  max_plus = max(max_plus,R2[N-1]);
  for (int i = 0; i < N - 1; i++) {
    max_plus = max(max_plus,R1[i]+R2[i+1]);
  }
  cout << sum + max_plus << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:12: error: no matching function for call to 'max(int, ll&)'
   26 |     c = max(0,c);
      |         ~~~^~~~~
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:26:12: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   26 |     c = max(0,c);
      |         ~~~^~~~~
/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:26:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   26 |     c = max(0,c);
      |         ~~~^~~~~
a.cc:37:12: error: no matching function for call to 'max(int, ll&)'
   37 |     b = max(0,b);
      |         ~~~^~~~~
/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:37:12: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   37 |     b = max(0,b);
      |         ~~~^~~~~
/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:37:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   37 |     b = max(0,b);
      |         ~~~^~~~~