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

Submission #1296819

Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
∧＿∧
∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
（ ´_ゝ`）　/　 ⌒i
／　　　＼　 　  |　|
/　　 /￣￣￣￣/　　|
＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

typedef long long ll;
#define INF 1LL<<60
#define rrep(i,a,b) for(int i=a;i>=b;i--)
int N;
ll A[301010];
ll B[301010], C[301010];
//---------------------------------------------------------------------------------------------------
void _main() {
cin >> N;
rep(i, 0, N * 3) cin >> A[i];

priority_queue<ll> pre; ll sm = 0;
rep(i, 0, N * 3) {
pre.push(-A[i]);
sm += A[i];

if (N < pre.size()) {
ll p = pre.top(); pre.pop();
sm += p;
}

B[i] = sm;
}

priority_queue<ll> post; sm = 0;
rrep(i, N * 3 - 1, 0) {
post.push(A[i]);
sm += A[i];

if (N < post.size()) {
ll p = post.top(); post.pop();
sm -= p;
}

C[i] = sm;
}

ll ans = -INF;
rep(c, N, N * 2 + 1) ans = max(ans, B[c - 1] - C[c]);
cout << ans << endl;
}

#### Submission Info

Submission Time 2017-05-20 21:25:57+0900 D - 3N Numbers hamayanhamayan C++14 (GCC 5.4.1) 500 1761 Byte AC 75 ms 9076 KB

#### Judge Result

Score / Max Score 0 / 0 300 / 300 200 / 200
Status
 AC × 3
 AC × 27
 AC × 43
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt
Subtask 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 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 AC 2 ms 4352 KB
0_01.txt AC 2 ms 4352 KB
0_02.txt AC 2 ms 4352 KB
1_00.txt AC 2 ms 4352 KB
1_01.txt AC 2 ms 4352 KB
1_02.txt AC 2 ms 4352 KB
1_03.txt AC 2 ms 4352 KB
1_04.txt AC 2 ms 4352 KB
1_05.txt AC 2 ms 4352 KB
1_06.txt AC 2 ms 4352 KB
1_07.txt AC 2 ms 4352 KB
1_08.txt AC 2 ms 4352 KB
1_09.txt AC 2 ms 4352 KB
1_10.txt AC 2 ms 4352 KB
1_11.txt AC 2 ms 4352 KB
1_12.txt AC 2 ms 4352 KB
1_13.txt AC 2 ms 4352 KB
1_14.txt AC 2 ms 4352 KB
1_15.txt AC 2 ms 4352 KB
1_16.txt AC 2 ms 4352 KB
1_17.txt AC 2 ms 4352 KB
1_18.txt AC 2 ms 4352 KB
1_19.txt AC 2 ms 4352 KB
1_20.txt AC 3 ms 4352 KB
1_21.txt AC 3 ms 4352 KB
1_22.txt AC 3 ms 4352 KB
1_23.txt AC 3 ms 4352 KB
2_00.txt AC 34 ms 8948 KB
2_01.txt AC 48 ms 8948 KB
2_02.txt AC 51 ms 8948 KB
2_03.txt AC 51 ms 9076 KB
2_04.txt AC 52 ms 8948 KB
2_05.txt AC 52 ms 8948 KB
2_06.txt AC 52 ms 8948 KB
2_07.txt AC 52 ms 8948 KB
2_08.txt AC 43 ms 9076 KB
2_09.txt AC 44 ms 8948 KB
2_10.txt AC 44 ms 8948 KB
2_11.txt AC 42 ms 8948 KB
2_12.txt AC 74 ms 8948 KB
2_13.txt AC 75 ms 8948 KB
2_14.txt AC 75 ms 8948 KB
2_15.txt AC 75 ms 8948 KB