s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1
value | original_language stringclasses 11
values | filename_ext stringclasses 1
value | status stringclasses 1
value | cpu_time stringlengths 1 5 | memory stringlengths 1 7 | code_size stringlengths 1 6 | code stringlengths 1 539k |
|---|---|---|---|---|---|---|---|---|---|---|---|
s513865790 | p03658 | u601522790 | 1541708363 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 123 | n,k = map(int, input().split())
l = int(input())
l = sorted(l, reverse = True)
ans = 0
for i in k:
ans += l[i]
print(ans) |
s990219639 | p03658 | u090225501 | 1541191385 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 104 | n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
print(sum[:k]) |
s863141260 | p03658 | u853900545 | 1540516467 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 120 | n,k=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
c=0
for i in range(k):
c += l[-1-k]
print(c)
|
s273812508 | p03658 | u853900545 | 1540516432 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 117 | n,k=map(int,input().split())
l=list(map(int,input.split()))
l.sort()
c=0
for i in range(k):
c += l[-1-k]
print(c) |
s170168921 | p03658 | u424967964 | 1526915098 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 99 | n,k = map(int,input().split())
l = map(int,input().split())
l.sort(reverse=True)
print(sum(l[0:k])) |
s517044686 | p03658 | u424967964 | 1526915012 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 103 | n,k = map(int,input().split())
l = map(int,input().split())
l = l.sort(reverse=True)
print(sum(l[0:k])) |
s743364540 | p03658 | u039623862 | 1525844039 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 105 | n,k=map(int, input().split())
l = list(map(int, input().split()))
l.sort(reversed=True)
print(sum(l[:k])) |
s695028106 | p03658 | u803647747 | 1523596929 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 122 | N, K = map(int, input().split())
int_list = sorted(list(map(int, input().split())), reverse=True)
print(sum(int_list[:K]) |
s928635148 | p03658 | u319612498 | 1519432798 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 129 | n,k=map(int,input().split())
l=reversed(sorted(list(map(int,input().split()))))
sum=0
for i in range(k):
sum+=l[i]
print(sum) |
s961448775 | p03658 | u019584841 | 1519324716 | Python | Python (3.4.3) | py | Runtime Error | 20 | 3188 | 115 | n, k = list(map(int, input().split()))
l=[int(x) for x in input().split()]
l.sort()
l.reverse()
print(sum(l[0:K]))
|
s467833209 | p03658 | u019584841 | 1519324549 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 120 | n,k=map(int,input().split())
l=[int(i) for i in input().split()]
a=sorted(l)
for j in range(k):
s+=a[-(j+1):]
print(s) |
s100646021 | p03658 | u988832865 | 1512585780 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 103 | N, K = map(int, input().split())
l = sorted(map(int, input().split()), reversed=True)
print(sum(l[:K])) |
s367279962 | p03658 | u988832865 | 1512585744 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 102 | N, K = map(int, input().split())
l = soted(map(int, input().split()), reversed=True)
print(sum(l[:K])) |
s092292437 | p03658 | u988832865 | 1512585687 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 89 | N, K = map(int, input().split())
l = soted(map(int, input().split()))
print(sum(l[:-K]))
|
s169193663 | p03658 | u190405389 | 1504580617 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 115 | n, k = [int(x) for x in input().split()]
l = [int(y) for y in input().split()]
l.sort()
print(l[-1]+l[-2]+l[-3])
|
s783316741 | p03658 | u271063202 | 1502583437 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 133 | n,k=map(int,input().split())
a=[]
for i in range(n):
a+=map(input().split())
a.sort()
ans=0
for i in range(k):
ans+=a[i]
print(ans) |
s077355270 | p03658 | u271063202 | 1502583394 | Python | Python (3.4.3) | py | Runtime Error | 16 | 2940 | 131 | n,k=map(int,input().split())
a=[]
for i in range(n)
a+=map(input().split())
a.sort()
ans=0
for i in range(k)
ans+=a[i]
print(ans) |
s327099677 | p03658 | u100403673 | 1502528706 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 131 | N, K = input().split()
l = input().split()
l = list(map(int, l))
l.sort(reverse=True)
sum = 0
for i in range(K):
sum += l[i]
|
s097803644 | p03658 | u343437894 | 1502469389 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 149 | n, k = map(int, input().split(" "))
l = map(int, input().split(" "))
l.sort()
sum = 0
for i in range(n-k-1, n-1):
sum = sum + l[i]
print(sum)
|
s868768873 | p03658 | u343437894 | 1502469331 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 144 | n, k = map(int, input().split(" "))
l = map(int, input().split(" "))
l.sort()
sum = 0
for i in range(n-k,n):
sum = sum + l[i]
print(sum)
|
s116928690 | p03658 | u343437894 | 1502469289 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 138 | n, k = map(int, input().split(" "))
l = map(int, input().split(" "))
l.sort()
sum = 0
for i in range(n-k,n):
sum += l[i]
print(sum) |
s735019273 | p03658 | u650245944 | 1501632520 | Python | Python (3.4.3) | py | Runtime Error | 16 | 2940 | 172 | #!/usr/bin
# -*- cording: "utf-8" -*-
a, b = map(int, input().split())
c = list(map(int, input().split()))
c.sort(reverse=true)
for i in range(b):
x = x + c[i]
print(x) |
s330911910 | p03658 | u650245944 | 1501632154 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 170 | !/usr/bin
# -*- cording: "utf-8" -*-
a, b = map(int, input().split())
c = list(map(int, input().split()))
c.sort(reverse=true)
for i in range(b):
x = x + c[i]
print(x) |
s545458192 | p03658 | u049354454 | 1501366564 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 200 | # coding: utf-8
# Here your code !
a=input()
b=a.split(" ")
N=int(b[0])
K=int(b[1])
ans=[]
l=[]
for i in range(N):
l.append(int(input()))
for w in range(K):
ans.append(max(l))
print(sum(ans)) |
s163040169 | p03658 | u642905089 | 1500255706 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 117 | Inp = input()
Blist = Inp[1]
Blist.sort()
out = 0
for i in range(Imp[0,1]):
out += Blist[-(i+1)]
print(out) |
s371662356 | p03658 | u891212850 | 1500178155 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 242 | def solution(n, k, l_list):
l_list.sort(reverse=True)
result = sum(l_list[:k])
return result
N, K = [int(value) for value in input().split(' ')]
l_list = [int(value) for value in input().split(' ')]
print(solution(n, k, l_list)) |
s618427808 | p03658 | u384579799 | 1500177320 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 203 | # -*- coding: utf-8 -*-
import sys
N, K = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
X = range(K, -1, -1)
s = 0
for i in range(K, K-N+1, -1):
s += l[i]
print(l, s, X) |
s396538157 | p03658 | u272028993 | 1500176079 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2568 | 149 | n, k = map(int, raw_input().split())
a = map(int, raw_input().split())
a.sort(reverse = True)
ans = 0:
for i in xrange(k):
ans += a[i]
print ans
|
s533389612 | p03658 | u384579799 | 1500172600 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 202 | # -*- coding: utf-8 -*-
import sys
N, K = map(int, input().split())
l = list()
for i in range(N):
l.append( map( int, input().split() ) )
l.reverse()
for i in range(K)
sum += a[i]
print(sum) |
s180312847 | p03659 | u760771686 | 1598452754 | Python | Python (3.8.2) | py | Runtime Error | 112 | 30600 | 185 | N = int(input())
A = [0]+list(map(int,input().split()))
for i in range(1,N+1):
A[i] = A[i]+A[i-1]
ans = float('inf')
for i in range(1,N):
ans = min(ans, ans(A[N]-2*A[i]))
print(ans) |
s385004709 | p03659 | u612975321 | 1598373830 | Python | Python (3.8.2) | py | Runtime Error | 169 | 30692 | 196 | n = int(input())
a = list(map(int,input().split()))
total = sum(a)
s = 0
i = 0
ans = total + 1
while True:
s += a[i]
total -= a[i]
ans = min(ans, abs(s - total))
i += 1
print(ans) |
s879708260 | p03659 | u869790980 | 1597147455 | Python | PyPy2 (7.3.0) | py | Runtime Error | 462 | 84916 | 138 | n = raw_input()
ais = map(int, raw_input())
c = 0
s = sum(ais)
m = +float('inf')
for a in ais:
c += a
m = min(m, abs(c - s + c))
print m |
s857983749 | p03659 | u317779196 | 1595696169 | Python | PyPy3 (7.3.0) | py | Runtime Error | 93 | 74744 | 227 | import numpy as np
n = int(input())
a = np.array([int(i) for i in input().split()])
a_sum = a.sum()
#y = sum - x
ans = 10**15
for i in range(1,n):
x = a[:i].sum()
aa = abs(2 * x - a_sum)
ans = min(ans,aa)
print(ans) |
s130641592 | p03659 | u317779196 | 1595696066 | Python | PyPy3 (7.3.0) | py | Runtime Error | 103 | 74748 | 217 | import numpy as np
n = int(input())
a = np.array([int(i) for i in input().split()])
a_sum = a.sum()
ans = 10**15
for i in range(1,n):
x = a[:i].sum()
aa = np.abs(2 * x - a_sum)
ans = min(ans,aa)
print(ans) |
s934726452 | p03659 | u735891571 | 1595512451 | Python | Python (3.8.2) | py | Runtime Error | 73 | 30548 | 215 | N = int(input())
a = list(map(int, input().split()))
b = list(accumulate(a))
ma = b[-1]
mi = 10**10
for sunuke in b:
arai = ma - sunuke
if abs(sunuke - arai) < mi:
mi = abs(sunuke - arai)
print(mi) |
s557356188 | p03659 | u735891571 | 1595512433 | Python | PyPy3 (7.3.0) | py | Runtime Error | 122 | 100384 | 215 | N = int(input())
a = list(map(int, input().split()))
b = list(accumulate(a))
ma = b[-1]
mi = 10**10
for sunuke in b:
arai = ma - sunuke
if abs(sunuke - arai) < mi:
mi = abs(sunuke - arai)
print(mi) |
s939743097 | p03659 | u065099501 | 1594934690 | Python | Python (3.8.2) | py | Runtime Error | 2364 | 148268 | 448 | n=int(input())
a=list(map(int,input().split()))
cnt = n//2
print(a[:cnt],a[cnt:])
ans=abs(sum(a[:cnt]) - sum(a[cnt:]))
for i in range(1,cnt):
print(a[:cnt+i],a[cnt+i:])
if ans > abs(sum(a[:cnt+i]) - sum(a[cnt+i:])):
ans = abs(sum(a[:cnt+i]) - sum(a[cnt+i:]))
for i in range(1,cnt):
print(a[:cnt... |
s427792664 | p03659 | u562015767 | 1594363690 | Python | PyPy3 (7.3.0) | py | Runtime Error | 122 | 100288 | 248 | n = int(input())
a = list(map(int,input().split()))
l = [0]*n
l[0] = a[0]
for i in range(1,n):
l[i] = l[i-1] + a[i]
ans = 10**9+1
for i in range(len(l)-1):
x = l[i]
y = sum - l[i]
tmp = abs(x-y)
ans = min(ans,tmp)
print(ans)
|
s857668827 | p03659 | u926046014 | 1593995380 | Python | PyPy3 (7.3.0) | py | Runtime Error | 127 | 100356 | 233 | n=int(input())
a=list(map(int,input().split()))
from numpy import cumsum
left_cumsum=cumsum(a)
a.reverse()
right_cumsum=cumsum(a)
ans=10000000000
for i in range(n-1):
ans=min(ans,abs(left_cumsum[i]-right_cumsum[-i-2]))
print(ans) |
s921727214 | p03659 | u819135704 | 1593388975 | Python | Python (3.8.2) | py | Runtime Error | 81 | 31256 | 161 | N = int(input())
a = [int(i) for i in input().split()]
sum_a = sum(a)
b = []
c = 0
for i in range(N-1):
c += a[i]
b.append(abs(2*b-sum_a))
print(min(b))
|
s921970486 | p03659 | u750651325 | 1592668682 | Python | Python (3.8.2) | py | Runtime Error | 74 | 30628 | 212 | N = int(input())
a = list(map(int, input().split()))
ans = 10000000000
aa = sum(a)
for i in range(N-1):
sum_a = sum(a[:i+1])
sum_b = a-sum_a
sa = abs(sum_a-sum_b)
ans = min(ans, sa)
print(ans)
|
s962111941 | p03659 | u555767343 | 1591756077 | Python | PyPy3 (2.4.0) | py | Runtime Error | 241 | 76496 | 213 | N = int(input())
A = list(map(int, input().split()))
import numpy as np
sumA = np.cumsum(A)
ans = float('inf')
for i in range(0, N-1):
x = sumA[i]
y = sumA[-1] - x
ans = min(abs(x-y), ans)
print(ans) |
s538906814 | p03659 | u440975163 | 1591426326 | Python | PyPy3 (2.4.0) | py | Runtime Error | 164 | 38256 | 157 | n = int(input())
a = list(map(int, input().split()))
z = sum(a)
ln = []
x = 0
for i in range(1, n):
x += a[i]
ln.append(abs(z - 2 * a)
print(min(ln)) |
s001288984 | p03659 | u514118270 | 1591145925 | Python | PyPy3 (2.4.0) | py | Runtime Error | 167 | 38384 | 203 | mport itertools
N = int(input())
a = list(map(int,input().split()))
ruiseki = list(itertools.accumulate(a))
ans = 10**100
for i in range(N-1):
ans = min(ans,abs(sum(a[:i+1])-sum(a[i+1:])))
print(ans) |
s003416223 | p03659 | u263824932 | 1591061759 | Python | PyPy3 (2.4.0) | py | Runtime Error | 253 | 78032 | 422 | N=int(input())
a=input().split()
A=[int(b) for b in a]
first=A[0]
last=A[-1]
if N==2:
print(abs(first-last))
else:
average = sum(A) // 2
number = 0
del A[0]
del A[-1]
for a in range(N - 1):
number += A[a]
if number >= average:
break
a1 = abs(sum(A[:a]) + first - l... |
s756965941 | p03659 | u001769145 | 1590455887 | Python | Python (3.4.3) | py | Runtime Error | 88 | 24392 | 258 | # ABC067 C Splitting Pile
import itertools
import bisect
n = int(input())
a_list = [int(x) for x in input().split()]
c_list = list(itertools.accumulate(a_list))
_sum = c_list[-1]
_idx = bisect.bisect_left(c_list, _sum//2)
print(abs(_sum - 2*c_list[_idx])) |
s360676174 | p03659 | u860002137 | 1590256893 | Python | Python (3.4.3) | py | Runtime Error | 223 | 33064 | 312 | import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))
whole = a.sum()
div = np.abs(a.cumsum() - whole / 2).argmin()
if div == 0 or div == (n - 1):
print(min(np.abs(a[0] - a[1:].sum()), np.abs(a[:-1] - a[-1].sum())))
else:
print(np.abs(a[:div + 1].sum() - a[div + 1:].sum())) |
s657414082 | p03659 | u346395915 | 1589657414 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 289 | import sys
sys.stdin = open('test.txt')
n = int(input())
li = list(map(int, input().split()))
all_sum = sum(li)
x = 0
y = all_sum
ans = 10**18
for i in range(n):
x += li[i]
y -= li[i]
if ans >= abs(x-y):
ans = abs(x-y)
if i == n - 2:
break
print(ans) |
s875155774 | p03659 | u551109821 | 1589414899 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 25456 | 200 | from collections import deque
N = int(input())
a = list(map(int,input().split()))
value = []
for i in range(2,N):
x = sum(a[0:i])
y = sum(a[i:N])
value.append(abs(x-y))
print(min(value))
|
s546869322 | p03659 | u551109821 | 1589414682 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 25456 | 204 | from collections import deque
N = int(input())
a = list(map(int,input().split()))
value = deque()
for i in range(2,N):
x = sum(a[0:i])
y = sum(a[i:N])
value.append(abs(x-y))
print(min(value))
|
s006814971 | p03659 | u652656291 | 1588388281 | Python | Python (3.4.3) | py | Runtime Error | 2108 | 24812 | 185 | n = int(input())
A = list(map(int,input().split()))
A_sum = sum(A)
ans = 10**19
for i in range(n):
x = A[:i+1]
x_sum = sum(x)
z = abs(A_sum - 2*x_sum)
ans = min(ans,z)
print(b)
|
s086675116 | p03659 | u652656291 | 1588388224 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 24948 | 168 | n = int(input())
A = list(map(int,input().split()))
A_sum = sum(A)
ans = 10**19
for i in range(n):
x = sum(A[:i+1])
z = abs(A_sum -2*x)
ans = min(ans,z)
print(b)
|
s047483985 | p03659 | u652656291 | 1588387862 | Python | Python (3.4.3) | py | Runtime Error | 37 | 19068 | 160 | n = int(input())
A = [map(int,input().split())]
ans = 10**19
for i in range(n):
a = A[:i]
a_sum = sum(a)
b = abs(sum(A)-a_sum)
ans = min(ans,b)
print(b) |
s470556550 | p03659 | u308237681 | 1587931117 | Python | Python (3.4.3) | py | Runtime Error | 229 | 24832 | 258 | n = int(input())
a = list(map(int, input().split()))
x = y = 0
y_cnt = 1
candidate = []
for i in range(n-1):
x += a[i]
while y >= x or y_cnt+i+1 == n:
y += a[-y_cnt]
y_cnt += 1
candidate.append(abs(x - y))
print(min(candidate))
|
s535692666 | p03659 | u385649291 | 1587930451 | Python | PyPy3 (2.4.0) | py | Runtime Error | 267 | 76496 | 195 | # coding: utf-8
# Your code here!
N = int(input())
a =list(map(int,input().split()))
minit = []
for i in range(1,N):
a = abs(2*sum(a[0:i])-sum(a))
minit.append(a)
print(min(minit)) |
s042568386 | p03659 | u757584836 | 1586400119 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 182 | n = int(input())
v = list(map(int, input().split()))
t = [0]
s = 2000000000
for i in range(0, n):
t.append(t[i]+v[i])
for i in range(0, n-1):
s = min(s, abs(t[n]-t[i+1])
print(s) |
s789515603 | p03659 | u757584836 | 1586400048 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 179 | n = int(input())
v = list(map(int, input().split()))
t = [0]
s = 2000000000
for i in range(0, n):
t.append(t[i]+v[i])
for i in range(0, n-1):
s = min(s, abs(s-t[i+1])
print(s) |
s852346185 | p03659 | u545368057 | 1586012372 | Python | PyPy3 (2.4.0) | py | Runtime Error | 184 | 38384 | 1648 | import sys
sys.setrecursionlimit(100000)
from collections import defaultdict
edges = []
to = defaultdict(list) # 1から到達できるか
ot = defaultdict(list) # Nから到達できるか
N, M, P = map(int, input().split())
visited_toN = [False]*(N+1)
visited_fm1 = [False]*(N+1)
for i in range(M):
a,b,c = map(int, input().split())
a -= ... |
s047648255 | p03659 | u464205401 | 1586008416 | Python | Python (3.4.3) | py | Runtime Error | 69 | 24824 | 142 | n=int(input())
A=list(map(int,input().split()))
ans=10**9
sumA=sum(A)
for i in range(n-1):
x+=A[i]
ans=min(ans,abs(sumA-x*2))
print(ans) |
s495860402 | p03659 | u706159977 | 1585752570 | Python | Python (3.4.3) | py | Runtime Error | 69 | 24828 | 188 | n = int(input())
a = list(map(int, input().split()))
d = []
for i in range(n):
sum = sum+a[i]
d[i] = sum
for i in range(n):
d[i] = abs(sum[i]-d[i])
d.pop(0)
d.pop(n-1)
print(min(d)) |
s633004060 | p03659 | u141574039 | 1585625133 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 24636 | 261 | N=int(input())
A=list(map(int,input().split()))
C=[0]*(N);C[0]=abs(A[0]-sum(A[1:]));x=10**9;P=0
for i in range(1,N):
if N-i==1:
break
else:
C[i]=abs(C[i-1]+A[i]-sum(A[i+1:]))
if x>C[i]:
x=C[i]
p=i
print(abs(C[p-1]+A[p]-sum(A[p+1:]))) |
s173586325 | p03659 | u843135954 | 1584878395 | Python | Python (3.4.3) | py | Runtime Error | 245 | 28712 | 496 | import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
n = ni()
a = na()
import numpy as np
a = list(np.cumsum(a))
import bisect
ma = bisect.bisect_right(a,a[-1]/2)+1
mi = bisect.bi... |
s483463154 | p03659 | u843135954 | 1584878055 | Python | Python (3.4.3) | py | Runtime Error | 729 | 31568 | 505 | import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
n = ni()
a = na()
import numpy as np
a = list(np.cumsum(a))
import bisect
print(a)
ma = bisect.bisect_right(a,a[-1]/2)+1
mi = ... |
s215355288 | p03659 | u852690916 | 1584877613 | Python | PyPy3 (2.4.0) | py | Runtime Error | 257 | 73808 | 280 | N = int(input())
from bisect import bisect_left
from itertools import accumulate
a = map(int, input().split())
A = list(accumulate(a))
m = A[-1]//2
i = bisect_left(A, m)
ans1 = abs(A[-1] - A[i] - A[i])
ans2 = abs(A[-1] - A[i-1] - A[i-1]) if i >= 1 else ans1
print(min(ans1,ans2))
|
s177964271 | p03659 | u089142196 | 1584043682 | Python | Python (3.4.3) | py | Runtime Error | 38 | 20416 | 254 | N=int(input())
a=[0]*N
for i in range(N):
a[i]=int(input().split())
b=[0]*N
b[0]=a[0]
for i in range(1,N):
b[i]=b[i-1]+a[i]
x=[0]*N
y=[0]*N
z=[0]*N
for j in range(N):
x[j]=b[j]
y[j]=b[-1]-b[j]
z[j]=abs(x[j]-y[j])
print(min(z[:-1])) |
s481103010 | p03659 | u318029285 | 1583358278 | Python | Python (3.4.3) | py | Runtime Error | 71 | 24812 | 326 | N = int(input())
a = list(map(int, input().split()))
if len(a) == 2:
x = a[0]
y = a[-1]
print(abs(x-y))
exit()
total = sum(a)
mid = total//2
for i in range(1, N):
x += a[i]
if x <= mid:
continue
else:
print(min(abs(x-a[i]-(total - (x-a[i]))), abs(x-(total - x))))
... |
s624260388 | p03659 | u318029285 | 1583358238 | Python | Python (3.4.3) | py | Runtime Error | 69 | 23800 | 366 | N = int(input())
a = list(map(int, input().split()))
if len(a) == 2:
x = a[0]
y = a[-1]
print(abs(x-y))
exit()
total = sum(a)
mid = total//2
print(mid)
for i in range(1, N):
x += a[i]
if x <= mid:
continue
else:
print(x-(total - x))
print(min(abs(x-a[i]-(total - (... |
s316891863 | p03659 | u172569352 | 1583246166 | Python | Python (3.4.3) | py | Runtime Error | 80 | 24812 | 251 | N = int(input())
a = [int(i) for i in input().split()]
s = sum(a)
m = s - a[:1]
#print(m)
for i in range(2, N):
b = sum(a[:i])
c = s - b
#print(b)
#print(c)
if m > (abs(b-c)):
m = abs(b-c)
else:
break
print(m) |
s643397673 | p03659 | u172569352 | 1583246148 | Python | Python (3.4.3) | py | Runtime Error | 78 | 25060 | 250 | N = int(input())
a = [int(i) for i in input().split()]
s = sum(a)
m = s - a[:1]
print(m)
for i in range(2, N):
b = sum(a[:i])
c = s - b
#print(b)
#print(c)
if m > (abs(b-c)):
m = abs(b-c)
else:
break
print(m) |
s900094269 | p03659 | u904943473 | 1581319455 | Python | PyPy3 (2.4.0) | py | Runtime Error | 165 | 38384 | 212 | from itertools import accumulate
N = int(input())
lst = list(map(int, input().split()))
cumsum = list(accumulate(lst))
mi = 2 * 10 ** 9
su = cumsum[-1]
for i in cumsum:
mi = min(mi, abs(i - (su-i))
print(mi) |
s874184825 | p03659 | u042105122 | 1580190844 | Python | PyPy3 (2.4.0) | py | Runtime Error | 165 | 38384 | 693 | #include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
using namespace std;
typedef long long int ll;
typedef pair<int, int> Pii;
const ll mod = 1000000007;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n;... |
s590576512 | p03659 | u127499732 | 1580138827 | Python | Python (3.4.3) | py | Runtime Error | 70 | 24812 | 138 | n=int(input())
l=list(map(int,input().split()))
b,i=l10**9,1
while(i<n):
p=sum(l[:i])
q=sum(l[i:])
b=min(b,abs(p-q))
i+=1
print(b) |
s152775147 | p03659 | u609987416 | 1577420939 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 319 | n = int(input())
a = list(map(int, input().split()))
s = [0]
if (n == 2):
print(abs(a[0] - a[1]))
else:
for i in range(n):
s.append(a[i] + s[i])
b = 1e+9
j = 1
while j != n:
if (abs(s[j] - (s[n] - s[j])) < b):
b = abs(s[j] - (s[n] - s[j]))
j++
print(b) |
s132231582 | p03659 | u609987416 | 1577420879 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 320 | n = int(input())
a = list(map(int, input().split()))
s = [0]
if (n == 2):
print(abs(a[0] - a[1]))
else:
for i in range(n):
s.append(a[i] + s[i])
b = 1e+9
j = 1
while(j != n):
if (abs(s[j] - (s[n] - s[j])) < b):
b = abs(s[j] - (s[n] - s[j]))
j++
print(b) |
s470949941 | p03659 | u244416763 | 1577418848 | Python | Python (3.4.3) | py | Runtime Error | 189 | 24832 | 300 | n = int(input())
a = list(map(int, input().split()))
s = [0]
if (n == 2):
printf(abs(a[0] - a[1]))
else:
for i in range(n):
s.append(a[i] + s[i])
b = 1e+9
for j in range(n+1):
if (abs(s[j] - (s[n] - s[j])) < b):
b = abs(s[j] - (s[n] - s[j]))
print(b) |
s647686026 | p03659 | u540761833 | 1577214937 | Python | Python (3.4.3) | py | Runtime Error | 81 | 24948 | 225 | N = int(input())
a = list(map(int,input().split()))
suma = a[0]
suma2 = sum(a)
for i in range(N-2):
if 2*suma + a[i+1] -suma2 >= 0:
break
suma += a[i+1]
print(min(abs(2*suma+a[i] - suma2),abs(2*suma - suma2))) |
s668326195 | p03659 | u540761833 | 1577214853 | Python | Python (3.4.3) | py | Runtime Error | 77 | 24940 | 223 | N = int(input())
a = list(map(int,input().split()))
suma = a[0]
suma2 = sum(a)
for i in range(1,N-1):
if 2*suma + a[i] -suma2 >= 0:
break
suma += a[i]
print(min(abs(2*suma+a[i] - suma2),abs(2*suma - suma2))) |
s010406313 | p03659 | u626468554 | 1576039466 | Python | Python (3.4.3) | py | Runtime Error | 77 | 24832 | 286 | #n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))
n = int(input())
a = list(map(int,input().split()))
memo = sum(a)
a=a[0]
b=memo-a[0]
ans = abs(a-b)
for i in range(1,n-1):
a += a[i]
b -= a[i]
ans = min(ans,abs(a-b))
print(ans) |
s062978730 | p03659 | u088552457 | 1574657113 | Python | Python (3.4.3) | py | Runtime Error | 209 | 25120 | 249 | n = int(input())
sticks = list(map(int, input().split()))
s = sum(sticks)
a = []
sum_i = 0
for i, v in enumerate(sticks):
sum_i += v
if i == 0:
continue
if i == len(sticks) - 1:
continue
a.append(abs(s - 2*sum_i))
print(min(a))
|
s750538849 | p03659 | u638795007 | 1573780520 | Python | PyPy3 (2.4.0) | py | Runtime Error | 262 | 72048 | 604 | def examC():
N = I()
A = LI()
sumA = [0]*N
sumA[0] = A[0]
for i in range(N-1):
sumA[i+1] = sumA[i]+A[i+1]
cur = bisect.bisect_left(sumA,sumA[N-1]//2)
ans = abs(min(sumA[N-1] -sumA[cur]*2,sumA[cur+1]*2-sumA[N-1]))
print(ans)
import sys
import copy
import bisect
import heapq
from... |
s012682398 | p03659 | u814986259 | 1571834731 | Python | Python (3.4.3) | py | Runtime Error | 126 | 24948 | 195 | N=int(input())
a=list(map(int,input().split()))
S=[0]*(N+1)
for i in range(1,N+1):
S[i]=S[i-1]+a[i-1]
ans=floot("Inf")
for i in range(1,N):
tmp=abs(S[N]-S[i])
ans=min(ans,tmp)
print(ans) |
s345375596 | p03659 | u791838908 | 1570731726 | Python | Python (3.4.3) | py | Runtime Error | 36 | 19068 | 153 | N = int(input())
I = map(int, input().split())
minX = 1000000
for i in range(len(I)):
minX = min(minX, abs(sum(I[:-i]) - sum(I[-i:]) ) )
print(minX) |
s114804849 | p03659 | u791838908 | 1570731623 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 158 | int(input())
I = sorted(map(int, input().split()))
minX = 1000000
for i in range(len(I)):
minX = min(minX, abs(sum(I[:-i]) - sum(I[-i:]) ) )
print(minX) |
s524686709 | p03659 | u791838908 | 1570731520 | Python | Python (3.4.3) | py | Runtime Error | 140 | 23792 | 156 | K = int(input())
I = sorted(map(int, input().split()))
minX = 1000000
for i in range(I):
minX = min(minX, abs(sum(I[:-i]) - sum(I[-i:]) ) )
print(minX) |
s522852858 | p03659 | u474423089 | 1570152797 | Python | Python (3.4.3) | py | Runtime Error | 70 | 23800 | 282 | import math
def main():
n=int(input())
a=list(map(int,input().split(' ')))
ans =math.inf
s=0
rac=sum(a)
for i in a[:-1]:
s+=i
rac-=i
if abs(s-rac)<ans:
ans = abs(s-rac)
print(ans)
if __name__ == '__main__':
main()
|
s795644836 | p03659 | u670180528 | 1568334909 | Python | Python (3.4.3) | py | Runtime Error | 71 | 24064 | 131 | n,*a=map(int,open(0).read().split())
x=a[0]
y=a[1:]
ans=abs(x-y)
for i in a[1:-1]:
x+=i
y-=i
ans=min(ans,abs(x-y))
print(ans) |
s135744226 | p03659 | u661983922 | 1568172258 | Python | Python (3.4.3) | py | Runtime Error | 70 | 24800 | 166 | N = int(input())
l = list(map(int,input().split()))
ans = 100000000000000
S = sum(l)
for i in range(N):
x = x - l[i]
ans = min(ans, abs(x - (S - x)))
print(ans) |
s114680222 | p03659 | u661983922 | 1568172230 | Python | Python (3.4.3) | py | Runtime Error | 71 | 24824 | 166 | N = int(input())
l = list(map(int,input().split()))
ans = 100000000000000
s = sum(l)
for i in range(N):
x = x - l[i]
ans = min(ans, abs(x - (S - x)))
print(ans) |
s901887281 | p03659 | u492447501 | 1568089038 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 242 | import numpy as np
N = int(input())
*A, = map(int, input().split())
A = np.array(A)
min = float('INF')
for i in range(N-1):
min_temp = (np.abs(np.sum(A)-2*np.sum(A[0:i+1]))
if min_temp < min:
min = min_temp
print(min) |
s230746641 | p03659 | u146575240 | 1567457499 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 247 | C - Splitting Pile
N = int(input())
a = list(map(int, input().split()))
sum_s = a[0]
tmp = sum(a)//2
for i in range(1,N):
if sum_s < tmp:
sum_s += a[i]
else:
break
sum_a = sum(a) - sum_s
ans = abs(sum_s - sum_a)
print(ans) |
s379478530 | p03659 | u666198201 | 1566461143 | Python | Python (3.4.3) | py | Runtime Error | 96 | 24820 | 255 | N=int(input())
A=list(map(int,input().split()))
B=[0]*100000
total=0
mini=1000000000000000000
for i in range(N):
total+=A[i]
B[i]=total
for i in range(N):
if abs(B[i]-(B[N-1]-B[i]))<mini:
mini=abs(B[i] - (B[N - 1] - B[i]))
print(mini) |
s012398752 | p03659 | u666198201 | 1566461114 | Python | Python (3.4.3) | py | Runtime Error | 97 | 23792 | 257 | N=int(input())
A=list(map(int,input().split()))
B=[0]*100000
total=0
mini=1000000000000000000
for i in range(N):
total+=A[i]
B[i]=total
for i in range(N-1):
if abs(B[i]-(B[N-1]-B[i]))<mini:
mini=abs(B[i] - (B[N - 1] - B[i]))
print(mini) |
s790575811 | p03659 | u958421405 | 1566342910 | Python | Python (3.4.3) | py | Runtime Error | 213 | 32712 | 351 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
import sys
input = sys.stdin.readline
def main():
n = int(input())
a = list(map(int, input().split()))
SUM = sum(a)
ans = sys.maxint
for i in range(1, n):
ans = min(ans, abs(2 * sum(a[:i]) - SUM))
print(ans)
if __na... |
s961588104 | p03659 | u609738635 | 1564717068 | Python | Python (3.4.3) | py | Runtime Error | 1395 | 143820 | 390 | # -*- coding: utf-8 -*-
def main(N,A):
zenbu = sum(A)
part_sum = [A[0]]
ans = float("INF")
for i in range(1,N):
print(part_sum,zenbu-part_sum[-1])
ans = min(ans, abs(zenbu-2*part_sum[-1]))
part_sum.append(part_sum[-1]+A[i])
print(ans)
if __name__ == '__main__':
N ... |
s366439541 | p03659 | u614734359 | 1562953212 | Python | Python (3.4.3) | py | Runtime Error | 20 | 5620 | 153 | n = int(input())
a = [int(i) for i in input()]
aray,tmp,ans = sum(a),0,float('inf')
for i in a:
tmp += a
ans = min(ans,abs(tmp-aray))
print(ans)
|
s150163237 | p03659 | u044025551 | 1562186582 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 361 | right_list=[] #右に進む
left_list=[] #左に進む
diff_list=[] #差分
right_list.append(l[0])
left_list.append(l[n-1])
for i in range(1,n):
right_list.append(right_list[i-1]+l[i])
left_list.append(left_list[i-1]+l[n-1-i])
left_list.reverse()
for i in range(0,n-1):
diff_list.append(abs(right_list[i]-left_list[i+1]))
... |
s085415534 | p03659 | u612636296 | 1561423199 | Python | Python (3.4.3) | py | Runtime Error | 70 | 24828 | 315 | N = int(input())
a = list(map(int, input().split()))
x = 0
ABS = 0
min = -1
loop = 0
SUM = 0
for i in range(a):
SUM += i
for i in range(N-1):
for j in range(i + 1):
x += a[j]
else:
ABS = abs(2*x - SUM)
x = 0
if (min == -1 or min > ABS):
min = ABS
print(min) |
s331845315 | p03659 | u409064224 | 1561421054 | Python | Python (3.4.3) | py | Runtime Error | 190 | 24824 | 194 | a = int(input())
l = list(map(int,input().split()))
le,ri = 0,sum(l)
ans = 10**10
for i in range(len(l)-1):
le += l[i]
ri -= l[i]
ans = min(ans,abs(le-ri))
else:
print(min(ans)) |
s858875935 | p03659 | u409064224 | 1561421019 | Python | Python (3.4.3) | py | Runtime Error | 185 | 23796 | 188 | a = int(input())
l = list(map(int,input().split()))
le,ri = 0,sum(l)
ans = 10**10
for i in range(len(l)-1):
le += l[i]
ri -= l[i]
min(ans,abs(le-ri))
else:
print(min(ans)) |
s909572997 | p03659 | u970449052 | 1561184044 | Python | Python (3.4.3) | py | Runtime Error | 122 | 24376 | 181 | import bisect
n=int(input())
al=list(map(int,input().split()))
tl=al[:]
for i in range(1,n):
tl[i]=(tl[i-1]+tl[i])
ta=bisect.bisect_left(tl,tl[-1]/2)
print(abs(al[ta+1]-al[ta])) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.