Problem p03714 (python)

Fixed submission:
N = int(input())
array = [int(n) for n in input().split()]
import copy
import heapq
lst = [None for i in range(N + 1)]
left_lst = copy.deepcopy(lst)
right_lst = copy.deepcopy(lst)
left_array = array[:N]
right_array= [-n for n in array[-N:]]
l_sum = sum(left_array)
r_sum = sum(right_array)
heapq.heapify(left_array)
heapq.heapify(right_array)
left_lst[0] = l_sum
right_lst[0] = r_sum

for k in range(N, 2 * N):
    new_a, new_b = array[k], array[-k - 1]*-1
    heapq.heappush(left_array,new_a)
    heapq.heappush(right_array,new_b)
    old_a = heapq.heappop(left_array)
    l_sum += (new_a - old_a)
    left_lst[k - N + 1] = l_sum
    old_b = heapq.heappop(right_array)
    r_sum += (new_b - old_b)
    right_lst[k - N + 1] = r_sum
lst = [ a + b for a, b in zip(left_lst, list(reversed(right_lst)))]
print(max(lst))

Buggy submission (verdict: Runtime Error):
N = int(input())
array = [int(n) for n in input().split()]
import copy
import heapq

lst = [None for i in range(N + 1)]
left_lst = copy.deepcopy(lst)
right_lst = copy.deepcopy(lst)
right_array = heapq.heapify(array[:N])
left_array = heapq.heapify([-n for n in array[-N:]])
l_sum = sum(left_array)
r_sum = sum(right_array)
left_lst[0] = l_sum
right_lst[0] = r_sum

for k in range(N, 2 * N):
    new_a, new_b = array[k], array[-k - 1]*-1
    heapq.heappush(left_array,new_a)
    heapq.heappush(right_array,new_b)
    old_a = heapq.heappop(left_array)
    l_sum += (new_a - old_a)
    left_lst[k - N + 1] = l_sum
    right_array.append(new_b)
    old_b = heapq.heappop(right_array)
    r_sum += (new_b - old_b)
    right_lst[k - N + 1] = r_sum
lst = [a + b for a, b in zip(left_lst, list(reversed(right_lst)))]
print(max(lst))

Buggy submission (verdict: Runtime Error):
N = int(input())
array=[int(n) for n in input().split()]
    lst=[]
    left_array=array[:N]
    right_array=array[-N:]
    for i in range(N+1):
        for j in range(i):
            new_a=array[N+j+1]
            old_a=min(left_array)
            new_b=array[-N-j-1]
            old_b=min(right_array)
            left_array.append(new_a)
            left_array.remove(old_a)
            right_array.append(new_b)
            right_array.remove(old_b)
    lst.append(sum(left_array)-sum(right_array))
    print(max(lst))

Buggy submission (verdict: Runtime Error):
N = int(input())
array=[int(n) for n in input().split()]
lst=[]
for i in range(N+1):
    left_array=array[:N+i]
    print(left_array)
    l = sorted(left_array)[-N:]
    print('l:',l)
    right_array=array[N+i:]
    print(right_array)
    r = sorted(right_array)[:N]
    print('r:',r)
    ans = sum(l)-sum(r)
    print(ans)
    lst.append(ans)
print(max(lst))

Buggy submission (verdict: Runtime Error):
N = int(input())
array=[int(n) for n in input().split()]
lst=[]
for i in range(N+1):
    left_array=array[:N+i]
    l = sorted(left_array)[-N:]
    right_array=array[N+i:]
    r = sorted(right_array)[:N]
    ans = sum(l)-sum(r)
    lst.extend(ans)
print(lst)

Buggy submission (verdict: Runtime Error):
N = int(input())
array=[int(n) for n in input().split()]

lst=0
for i in range(N+1):
    left_array=array[:N+i]
    print(left_array)
    l = sorted(left_array)[-N:]
    print('l:',l)
    right_array=array[N+i:]
    print(right_array)
    r = sorted(right_array)[:N]
    print('r:',r)
    ans = sum(l)-sum(r)
    print(ans)
    if ans > lst:
        lst= ans
print(lst)

Buggy submission (verdict: Runtime Error):
N = int(input())
array=[int(n) for n in input().split()]

lst=0
for i in range(N+1):
    left_array=array[:N+i]
    print(left_array)
    l = sorted(left_array)[-N:]
    print('l:',l)
    right_array=array[-int(N)+i-3:]
    print(right_array)
    r = sorted(right_array)[:N]
    print('r:',r)
    ans = sum(l)-sum(r)
    print(ans)
    if ans > lst:
        lst= ans
print(lst)

Buggy submission (verdict: Runtime Error):
N = input()
array= input().split()
left_array=array[:array/3+1]
mid_array= array[array/3+1:-array/3]
right_array= array[-array/3]
lst=0
for i in N:
    left_array=array[:array/3+i+1]
    l = left_array.sort()[i+1:]
    right_array=array[-array/3+i+1:]
    r = right_array.sort(reverse=True)[N-i-1:]
    ans = sum(abs(l-r))
    if ans > lst:
        lst= ans
print(lst)

Buggy submission (verdict: Runtime Error):
N = input()
array= input().split()
left_array=array[:array/3+1]
mid_array= array[array/3+1:-array/3]
right_array= array[-array/3]
lst=[]
for i in N:
    left_array=array[:array/3+i+1]
    l = left_array.sort()[i+1:]
    right_array=array[-array/3+i+1:]
    r = right_array.sort(reverse=True)[N-i-1:]
    ans = sum(abs(l-r))
    if ans > lst:
        lst= ans
print(lst)