Contest Duration: ~ (local time) (100 minutes) Back to Home

Submission #1300114

Source Code Expand

Copy
```#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
int N;
cin >> N;
vector<int> a(3 * N);
REP (i, 0, a.size()) cin >> a[i];
lli ans = -(1LL << 60);
vector<lli> bl(N + 1, 0);
vector<lli> br(N + 1, 0);

priority_queue<lli, vector<lli>, greater<lli>> pql;
REP (i, 0, N) pql.push(a[i]);
lli lsum = 0;
REP (i, 0, N) lsum += a[i];
lli rsum = 0;
REP (i, 2 * N, 3 * N) rsum += a[i];
bl[0] = lsum;
br[N] = rsum;

REP (border, N, 2 * N) {
int t = pql.top();
if (t < a[border]) {
pql.pop();
pql.push(a[border]);
lsum -= t;
lsum += a[border];
}
bl[border - N + 1] = lsum;
}

priority_queue<lli, vector<lli>> pqr;
REP (i, 2 * N, 3 * N) pqr.push(a[i]);
for (int border = 2 * N - 1; border >= N; border--) {
int t = pqr.top();
if (t > a[border]) {
pqr.pop();
pqr.push(a[border]);
rsum -= t;
rsum += a[border];
}
br[border - N] = rsum;
}

REP (i, 0, N + 1) {
ans = max(ans, bl[i] -br[i]);
}

cout << ans << endl;
return 0;
}
```

#### Submission Info

Submission Time 2017-05-20 23:19:16+0900 D - 3N Numbers commy C++14 (GCC 5.4.1) 500 1401 Byte AC 143 ms 5364 KB

#### Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 0_00.txt, 0_01.txt, 0_02.txt
Subtask 300 / 300 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt
All 200 / 200 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 2_00.txt, 2_01.txt, 2_02.txt, 2_03.txt, 2_04.txt, 2_05.txt, 2_06.txt, 2_07.txt, 2_08.txt, 2_09.txt, 2_10.txt, 2_11.txt, 2_12.txt, 2_13.txt, 2_14.txt, 2_15.txt
Case Name Status Exec Time Memory
0_00.txt 1 ms 256 KB
0_01.txt 1 ms 256 KB
0_02.txt 1 ms 256 KB
1_00.txt 1 ms 256 KB
1_01.txt 1 ms 256 KB
1_02.txt 1 ms 256 KB
1_03.txt 1 ms 256 KB
1_04.txt 1 ms 256 KB
1_05.txt 1 ms 256 KB
1_06.txt 1 ms 256 KB
1_07.txt 1 ms 256 KB
1_08.txt 2 ms 256 KB
1_09.txt 3 ms 256 KB
1_10.txt 2 ms 256 KB
1_11.txt 2 ms 256 KB
1_12.txt 2 ms 256 KB
1_13.txt 2 ms 256 KB
1_14.txt 2 ms 256 KB
1_15.txt 2 ms 256 KB
1_16.txt 2 ms 256 KB
1_17.txt 2 ms 256 KB
1_18.txt 2 ms 256 KB
1_19.txt 2 ms 256 KB
1_20.txt 3 ms 256 KB
1_21.txt 3 ms 256 KB
1_22.txt 3 ms 256 KB
1_23.txt 3 ms 256 KB
2_00.txt 51 ms 5364 KB
2_01.txt 132 ms 5364 KB
2_02.txt 113 ms 5236 KB
2_03.txt 107 ms 5236 KB
2_04.txt 107 ms 5236 KB
2_05.txt 108 ms 5364 KB
2_06.txt 108 ms 5364 KB
2_07.txt 103 ms 5364 KB
2_08.txt 58 ms 5236 KB
2_09.txt 57 ms 5236 KB
2_10.txt 58 ms 5236 KB
2_11.txt 57 ms 5236 KB
2_12.txt 141 ms 5236 KB
2_13.txt 143 ms 5236 KB
2_14.txt 142 ms 5364 KB
2_15.txt 142 ms 5236 KB