Submission #2780258


Source Code Expand

Copy
from heapq import heapify, heappushpop

n = int(input())
xs = [int(x) for x in input().split()]

xs1 = xs[:n]
heapify(xs1)
r1 = [sum(xs1)]
for x in xs[n:2*n]:
    r1.append(r1[-1] + x - heappushpop(xs1, x))

xs2 = [-x for x in xs[2*n:]]
heapify(xs2)
r2 = [sum(xs2)]
for x in reversed(xs[n:2*n]):
    r2.append(r2[-1] + (-x) - heappushpop(xs2, -x))

print(max(a+b for a,b in zip(r1, reversed(r2))))

Submission Info

Submission Time
Task D - 3N Numbers
User zehnpaard
Language Python3 (3.4.3)
Score 500
Code Size 414 Byte
Status
Exec Time 321 ms
Memory 40340 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 18 ms 3064 KB
0_01.txt 18 ms 3064 KB
0_02.txt 18 ms 3064 KB
1_00.txt 18 ms 3064 KB
1_01.txt 18 ms 3064 KB
1_02.txt 18 ms 3064 KB
1_03.txt 18 ms 3064 KB
1_04.txt 18 ms 3064 KB
1_05.txt 18 ms 3064 KB
1_06.txt 18 ms 3064 KB
1_07.txt 18 ms 3064 KB
1_08.txt 19 ms 3188 KB
1_09.txt 20 ms 3444 KB
1_10.txt 20 ms 3316 KB
1_11.txt 20 ms 3316 KB
1_12.txt 19 ms 3316 KB
1_13.txt 20 ms 3316 KB
1_14.txt 19 ms 3316 KB
1_15.txt 19 ms 3316 KB
1_16.txt 19 ms 3188 KB
1_17.txt 19 ms 3188 KB
1_18.txt 19 ms 3188 KB
1_19.txt 19 ms 3188 KB
1_20.txt 20 ms 3444 KB
1_21.txt 20 ms 3444 KB
1_22.txt 20 ms 3444 KB
1_23.txt 20 ms 3444 KB
2_00.txt 162 ms 15716 KB
2_01.txt 200 ms 40340 KB
2_02.txt 246 ms 28296 KB
2_03.txt 224 ms 29100 KB
2_04.txt 209 ms 29100 KB
2_05.txt 215 ms 27400 KB
2_06.txt 213 ms 27404 KB
2_07.txt 187 ms 29100 KB
2_08.txt 180 ms 15508 KB
2_09.txt 190 ms 16108 KB
2_10.txt 188 ms 16148 KB
2_11.txt 185 ms 15420 KB
2_12.txt 302 ms 36420 KB
2_13.txt 303 ms 36900 KB
2_14.txt 302 ms 36212 KB
2_15.txt 321 ms 40196 KB