Submission #2559361


Source Code Expand

import heapq
N = int(input())
A = [int(i) for i in input().split()]
posi=[]
posidata=[]
nega=[]
negadata=[]
for i in range(N):
    heapq.heappush(posi,A[i])
    heapq.heappush(nega,-A[3*N-1-i])
posisum = sum(posi)
negasum = sum(nega)
posidata.append(posisum)
negadata.append(negasum)
for i in range(N):
    heapq.heappush(posi,A[N+i])
    a = heapq.heappop(posi)
    posisum += A[N+i]-a
    posidata.append(posisum)
    heapq.heappush(nega,-A[2*N-1-i])
    b = heapq.heappop(nega)
    negasum += -A[2*N-1-i]-b
    negadata.append(negasum)
print(max(posidata[i]+negadata[-1-i] for i in range(N+1)))
    

Submission Info

Submission Time
Task D - 3N Numbers
User okumura
Language Python (3.4.3)
Score 500
Code Size 626 Byte
Status AC
Exec Time 542 ms
Memory 38292 KB

Judge Result

Set Name Sample Subtask All
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 17 ms 3064 KB
0_01.txt AC 18 ms 3064 KB
0_02.txt AC 18 ms 3064 KB
1_00.txt AC 18 ms 3064 KB
1_01.txt AC 18 ms 3064 KB
1_02.txt AC 18 ms 3064 KB
1_03.txt AC 18 ms 3064 KB
1_04.txt AC 18 ms 3064 KB
1_05.txt AC 18 ms 3064 KB
1_06.txt AC 18 ms 3064 KB
1_07.txt AC 18 ms 3064 KB
1_08.txt AC 21 ms 3188 KB
1_09.txt AC 21 ms 3444 KB
1_10.txt AC 21 ms 3316 KB
1_11.txt AC 21 ms 3316 KB
1_12.txt AC 21 ms 3316 KB
1_13.txt AC 21 ms 3316 KB
1_14.txt AC 21 ms 3316 KB
1_15.txt AC 21 ms 3316 KB
1_16.txt AC 21 ms 3188 KB
1_17.txt AC 21 ms 3188 KB
1_18.txt AC 21 ms 3188 KB
1_19.txt AC 21 ms 3188 KB
1_20.txt AC 22 ms 3444 KB
1_21.txt AC 22 ms 3444 KB
1_22.txt AC 22 ms 3444 KB
1_23.txt AC 21 ms 3444 KB
2_00.txt AC 373 ms 15000 KB
2_01.txt AC 417 ms 38292 KB
2_02.txt AC 409 ms 29100 KB
2_03.txt AC 437 ms 28296 KB
2_04.txt AC 415 ms 29064 KB
2_05.txt AC 421 ms 27400 KB
2_06.txt AC 421 ms 27400 KB
2_07.txt AC 430 ms 27404 KB
2_08.txt AC 383 ms 15952 KB
2_09.txt AC 388 ms 16812 KB
2_10.txt AC 377 ms 17364 KB
2_11.txt AC 375 ms 16764 KB
2_12.txt AC 520 ms 36420 KB
2_13.txt AC 521 ms 36212 KB
2_14.txt AC 542 ms 36212 KB
2_15.txt AC 525 ms 36780 KB