Language: C++

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

typedef long long ll;

#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)

int main() {
    int N; cin >> N;
    ll a[300100]; FOR(i, 0, 3 * N) cin >> a[i];

    priority_queue<ll, vector<ll>, greater<ll>> pque_front;
    priority_queue<ll> pque_back;

    ll sum1= 0, sum2 = 0;

    FOR(j, 0, N) {
        sum1 += a[j];
        pque_front.push(a[j]);
    }

    FOR(j, 2 * N , 3 * N) {
        sum2 += a[j];
        pque_back.push(a[j]);
    }

    ll sum1[300100], sum2[300100];

    sum1[N - 1] = sum1;
    sum2[2 * N] = sum2;

    ll ans = sum1 - sum2;

    FOR(j, N , 2 * N ){
        sum1[j] = sum[j - 1] + a[j];
        pque_front.push(a[j]);
        sum1[j] = sum[j - 1] - pque_front.top();
        pque_front.pop();
        
        sum2[3 * N - 1 - j] = sum2[3 * N - j] + a[3 * N - 1 - j];
        pque_back.push(a[j]);
        sum2[3 * N - 1 - j] = sum2[3 * N - j] - pque_back.top();
        pque_back.pop();
    }
    
    FOR(j, N , 2 * N ){
        ll sum = sum1[j] - sum2[3 * N - 1 - j];
        ans = max(ans, sum);
    }


    printf("%lld\n", ans);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:8: error: conflicting declaration 'll sum1 [300100]'
   29 |     ll sum1[300100], sum2[300100];
      |        ^~~~
a.cc:17:8: note: previous declaration as 'll sum1'
   17 |     ll sum1= 0, sum2 = 0;
      |        ^~~~
a.cc:29:22: error: conflicting declaration 'll sum2 [300100]'
   29 |     ll sum1[300100], sum2[300100];
      |                      ^~~~
a.cc:17:17: note: previous declaration as 'll sum2'
   17 |     ll sum1= 0, sum2 = 0;
      |                 ^~~~
a.cc:31:9: error: invalid types 'll {aka long long int}[int]' for array subscript
   31 |     sum1[N - 1] = sum1;
      |         ^
a.cc:32:9: error: invalid types 'll {aka long long int}[int]' for array subscript
   32 |     sum2[2 * N] = sum2;
      |         ^
a.cc:37:13: error: invalid types 'll {aka long long int}[int]' for array subscript
   37 |         sum1[j] = sum[j - 1] + a[j];
      |             ^
a.cc:37:19: error: 'sum' was not declared in this scope; did you mean 'sum2'?
   37 |         sum1[j] = sum[j - 1] + a[j];
      |                   ^~~
      |                   sum2
a.cc:39:13: error: invalid types 'll {aka long long int}[int]' for array subscript
   39 |         sum1[j] = sum[j - 1] - pque_front.top();
      |             ^
a.cc:42:13: error: invalid types 'll {aka long long int}[int]' for array subscript
   42 |         sum2[3 * N - 1 - j] = sum2[3 * N - j] + a[3 * N - 1 - j];
      |             ^
a.cc:42:35: error: invalid types 'll {aka long long int}[int]' for array subscript
   42 |         sum2[3 * N - 1 - j] = sum2[3 * N - j] + a[3 * N - 1 - j];
      |                                   ^
a.cc:44:13: error: invalid types 'll {aka long long int}[int]' for array subscript
   44 |         sum2[3 * N - 1 - j] = sum2[3 * N - j] - pque_back.top();
      |             ^
a.cc:44:35: error: invalid types 'll {aka long long int}[int]' for array subscript
   44 |         sum2[3 * N - 1 - j] = sum2[3 * N - j] - pque_back.top();
      |                                   ^
a.cc:49:22: error: invalid types 'll {aka long long int}[int]' for array subscript
   49 |         ll sum = sum1[j] - sum2[3 * N - 1 - j];
      |                      ^
a.cc:49:32: error: invalid types 'll {aka long long int}[int]' for array subscript
   49 |         ll sum = sum1[j] - sum2[3 * N - 1 - j];
      |                                ^