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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s118662985 | p03739 | u191423660 | 1597540355 | Python | Python (3.8.2) | py | Runtime Error | 113 | 20084 | 1236 | def solve():
n = int(input())
a = list(map(int, input().split()))
b = [a[i] for i in range(n)]
# print(a)
# print(b)
i = 0
sum = 0
ans = 0
for i in range(n-1):
sum += a[i]
if sum > 0 and sum+a[i+1] > 0:
tmp = -1 - sum
ans += abs(tmp - a[i+1]... |
s802299545 | p03739 | u191423660 | 1597540286 | Python | Python (3.8.2) | py | Runtime Error | 117 | 20168 | 1236 | def solve():
n = int(input())
a = list(map(int, input().split()))
b = [a[i] for i in range(n)]
# print(a)
# print(b)
i = 0
sum = 0
ans = 0
for i in range(n-1):
sum += a[i]
if sum > 0 and sum+a[i+1] > 0:
tmp = -1 - sum
ans += abs(tmp - a[i+1]... |
s388681912 | p03739 | u281152316 | 1595195744 | Python | Python (3.8.2) | py | Runtime Error | 97 | 19928 | 450 | n = int(input())
A = list(map(int,input().split()))
ans = 0
x = 0
S = []
S.append(A[0])
for i in range(1,n):
x = A[i] + S[i - 1]
if S[i - 1] > 0:
if x >= 0:
x = - x - 1
ans += abs(x)
S.append(-1)
else:
S.append(x)
elif S[i - 1] < 0:
if ... |
s548451778 | p03739 | u281152316 | 1595195673 | Python | Python (3.8.2) | py | Runtime Error | 104 | 19936 | 450 | n = int(input())
A = list(map(int,input().split()))
ans = 0
x = 0
S = []
S.append(A[0])
for i in range(1,n):
x = A[i] + S[i - 1]
if S[i - 1] > 0:
if x >= 0:
x = - x - 1
ans += abs(x)
S.append(-1)
else:
S.append(x)
elif S[i - 1] < 0:
if ... |
s541648051 | p03739 | u961288441 | 1593086568 | Python | Python (3.8.2) | py | Runtime Error | 93 | 19932 | 359 | n = int(input())
a = list(map(int, input().split()))
point = a[0]
ans = 0
for i in a[1:]:
if point*i < 0:
if abs(point) < abs(i):
point += i
else:
ans += (abs(point)+1) - abs(i)
point = -int(point/abs(point))
else:
ans += (abs(point)+1) + i
po... |
s314061533 | p03739 | u984276646 | 1592893654 | Python | Python (3.8.2) | py | Runtime Error | 52 | 19936 | 99 | n = int(input())
a = list(map(int, input().split()))
if a[0] != 0:
print(0)
else:
print(a[n+4]) |
s527569907 | p03739 | u781262926 | 1592420427 | Python | Python (3.4.3) | py | Runtime Error | 182 | 21652 | 435 | n, *A = map(int, open(0).read().split())
B = [A[0]]
C = [A[0]]
D = [0]
for i in range(1, n):
if (C[i-1] + A[i]) * C[i-1] < 0:
B.append(A[i])
C.append(C[i-1] + A[i])
D.append(D[i-1])
else:
if C[i-1] > 0:
B.append(-(C[i-1]+1))
C.append(-1)
D.append(C[i-1]+1 + A[i])
elif C[i-1] < ... |
s593524965 | p03739 | u679520304 | 1591678194 | Python | PyPy3 (2.4.0) | py | Runtime Error | 170 | 38256 | 1106 | n = int(input())
a = list(map(int,input().split()))
num = a[0]
ans = 0
if a[0]>0:
for i in range(1,n):
num += a[i]
if i%2==1:
if num>=0:
ans += num+1
num = -1
else:
if num<=0:
ans += 1-num
num = 1
elif a[... |
s223925107 | p03739 | u679520304 | 1591144306 | Python | PyPy3 (2.4.0) | py | Runtime Error | 236 | 63216 | 1110 | n = int(input())
a = list(map(int,input().split()))
num = a[0]
ans = 0
if a[0]>0:
for i in range(1,n):
num += a[i]
if i%2==1:
if num>=0:
ans += num+1
num = -1
else:
if num<=0:
ans += 1-num
num = 1
elif a[... |
s819339000 | p03739 | u472883337 | 1591062277 | Python | Python (3.4.3) | py | Runtime Error | 161 | 14332 | 927 | n = int(input())
a = list(map(int, input().split()))
l = len(a)
b = [int(-a[0]/ abs(a[0]))]
for i in range(1, l):
b.append(a[i])
ans = 0
summary = a[0]
if(summary == 0):
if(a[1] > 0):
summary = -1
ans+= 1
else:
summary = 1
ans+= 1
for i in range(1, l):
if(summary* (summary+ a[i])>= 0):
if(... |
s970990080 | p03739 | u086503932 | 1590724584 | Python | Python (3.4.3) | py | Runtime Error | 90 | 14212 | 846 | #!/usr/bin/env python3
from itertools import accumulate
def main():
n = int(input())
a = list(map(int, input().split()))
a = list(accumulate(a))
if a[0] != 0:
ans = 0
diff = 0
for i in range(1,n):
p = a[i] + diff
q = a[i-1] + diff
if p * ... |
s334857872 | p03739 | u392319141 | 1589248968 | Python | Python (3.4.3) | py | Runtime Error | 135 | 14464 | 429 | N = int(input())
A = list(map(int, input().split()))
def sol(S):
ret = 0
B = [S]
for a in A[1:]:
b = a
if S * (S + b) > 0:
b = (abs(S) + 1) * (1 if S < 0 else -1)
if S + b == 0:
b = b - 1 if b < 0 else b + 1
ret += abs(b - a)
S += b
B.... |
s044712159 | p03739 | u977193988 | 1589130393 | Python | Python (3.4.3) | py | Runtime Error | 101 | 14460 | 2564 | import sys
def input():
return sys.stdin.readline().strip()
sys.setrecursionlimit(20000000)
def main():
N = int(input())
A = list(map(int, input().split()))
if A[0] == 0:
answer = []
for a in (1, -1):
cnt = 1
S = a
for i in range(1, N):
... |
s987640330 | p03739 | u855378574 | 1589055453 | Python | PyPy3 (2.4.0) | py | Runtime Error | 164 | 38480 | 677 | N = int(input())
A = list(map(int, input().split()))
counter = 0 ####操作回数
A.reverse()
S = 0
a = A.pop()
if a==0:
counter += 1
while A:
b = A.pop()
if b == 0:
counter += 2
elif b>0:
A.append(b)
S = -1
break
elif b<0:
A.append(b)
S = 1
br... |
s253978364 | p03739 | u097317219 | 1588966571 | Python | PyPy3 (2.4.0) | py | Runtime Error | 174 | 38384 | 382 | def sign(x):
if x<0:
return -1
elif x>0:
return 1
else:
retrun 0
n = int(input())
a = list(map(int,input().split()))
cumulative_sum = a[0]
flag = sign(cumulative_sum)
ans = 0
for i in range(1,n):
cumulative_sum += a[i]
if sign(cumulative_sum) == flag or sign(cumulative_sum) == 0:
ans += abs(-f... |
s645544847 | p03739 | u679520304 | 1588827954 | Python | PyPy3 (2.4.0) | py | Runtime Error | 231 | 63216 | 449 | n = int(input())
a = list(map(int,input().split()))
A = a[0]
for i in range(1,n):
num = abs(A)+1
if A*(A+a[i])<0:
A += a[i]
elif A+a[i]==0:
if A>0:
A += a[i]-num
ans += num
else:
A += a[i]+num
ans += num
elif A*(A+a[i])>0:
i... |
s829175591 | p03739 | u103520789 | 1588824106 | Python | PyPy3 (2.4.0) | py | Runtime Error | 191 | 55920 | 253 | from functools import reduce
N =int(input())
A = map(int, input().split())
def check(A):
arr = [0]*(N+1)
for i in range(len(A)):
arr[i+1] += arr[i-1] + ai
if arr[i+1]*arr[i] <=0:
return 0
val = abs(min(arr))
return val
print(val) |
s378455420 | p03739 | u607074939 | 1588813335 | Python | Python (3.4.3) | py | Runtime Error | 126 | 14332 | 286 | n = int(input())
a = list(map(int,input().split()))
sum_a = a[0]
cnt = 0
for i in range(1,n):
if sum_a*(sum_a+a[i]) < 0:
sum_a += a[i]
else:
tmp = a[i]
a[i] = int(-sum_a -a[i-1]/abs(a[i-1]))
sum_a += a[i]
cnt += abs(a[i]-tmp)
print(cnt) |
s899084624 | p03739 | u934868410 | 1588699764 | Python | Python (3.4.3) | py | Runtime Error | 133 | 14468 | 519 | n = int(input())
a = list(map(int, input().split()))
s, ans, i = 0, 0, 0
while a[i] == 0 and i < n:
ans += 2
i += 1
ans = max(0, ans - 1)
if i == n:
print(ans)
exit()
if ans > 0:
ans -= 1
if abs(a[i]) == 1:
ans += 1
s = a[i] // abs(a[i])
else:
s = a[0]
i += 1
for j in range... |
s772741089 | p03739 | u934868410 | 1588699487 | Python | Python (3.4.3) | py | Runtime Error | 128 | 14468 | 506 | n = int(input())
a = list(map(int, input().split()))
s, ans, i = 0, 0, 0
while a[i] == 0 and i < n:
ans += 2
i += 1
ans = max(0, ans - 1)
if i == n:
print(ans)
exit()
if ans > 0:
if abs(a[i]) == 1:
ans += 1
s = a[i] // abs(a[i])
else:
s = a[0]
i += 1
for j in range(i, n):
i... |
s326706965 | p03739 | u934868410 | 1588699245 | Python | Python (3.4.3) | py | Runtime Error | 136 | 14468 | 502 | n = int(input())
a = list(map(int, input().split()))
s, ans, i = 0, 0, 0
while a[i] == 0 and i < n:
ans += 2
i += 1
ans = max(0, ans - 1)
if i == n:
print(ans)
exit()
if ans > 0:
if abs(a[i]) == 1:
ans += 1
s = a[i] // abs(a[i])
else:
s = a[0]
i += 1
for j in range(i, n):
i... |
s813745966 | p03739 | u934868410 | 1588698891 | Python | Python (3.4.3) | py | Runtime Error | 130 | 14468 | 446 | n = int(input())
a = list(map(int,input().split()))
s, ans, i = 0,0,0
while a[i] == 0 and i < n:
ans += 2
i += 1
ans = max(0, ans - 1)
if i == n:
print(ans)
exit()
if ans > 0:
if abs(a[i]) == 1:
ans += 1
s = a[i] // abs(a[i])
else:
s = a[0]
i += 1
for j in range(i,n):
if abs(a[j]) > abs(s) and a... |
s701083851 | p03739 | u190079347 | 1588476415 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3188 | 616 | a = list(map(int,input().split()))
def judge(count):
idx = 0
for i in range(2,n+1):
if count == -1:
if sum(a[0:i]) < 0:
pass
else:
check = sum(a[0:i]) + 1
j = a[i-1]
a[i-1] = j - check
idx += check
elif count == 1:
if sum(a[0:i]) > 0:
pass
... |
s330953217 | p03739 | u949442192 | 1588186605 | Python | Python (3.4.3) | py | Runtime Error | 24 | 6124 | 924 | def resolve(SL):
# L[0]!=0を起点とする
cnt = 0
for i in range(len(SL)-1):
s0 = SL[i]
s1 = SL[i+1]
if(s0>0 and s1>=0):
SL[(i+1):] = [s-(s1+1) for s in SL[(i+1):]]
cnt += (s1+1)
elif(s0<0 and s1<=0):
SL[(i+1):] = [s+(-s1+1) for s in SL[(i+1):]]
... |
s752354178 | p03739 | u576432509 | 1587839155 | Python | Python (3.4.3) | py | Runtime Error | 44 | 14464 | 767 | n=int(input())
a=list(map(int,input().split()))
# 0 1 2 3 evn odd
# kevn + - + - + -
# kodd - + - + - +
def kf(a,flag):
a0=a[0]*flag
if a0<=0:
kevn=1-a0
sevn=1
elif a0>0:
kevn=0
sevn=a0
for i in range(1,n):
ai=a[i]*flag
if i%2==0:
... |
s857888878 | p03739 | u626217906 | 1587512611 | Python | PyPy3 (2.4.0) | py | Runtime Error | 237 | 63772 | 1902 | import copy
n = int(input())
a = list(map(int,input().split()))
a_1 = a.copy()
ans = 0
ans_2 = 0
o = 0
for i in range(n):
if i == 0:
if a[i] == 0:
f = "+"
a[i] = 1
elif a[0] > 0:
f = "+"
elif a[0] < 0:
f = "-"
else:
o += a[i-1]
... |
s233679099 | p03739 | u626217906 | 1587512553 | Python | PyPy3 (2.4.0) | py | Runtime Error | 247 | 63772 | 1902 | import copy
n = int(input())
a = list(map(int,input().split()))
a_1 = a.copy()
ans = 0
ans_2 = 0
o = 0
for i in range(n):
if i == 0:
if a[i] == 0:
f = "+"
a[i] = 1
elif a[0] > 0:
f = "+"
elif a[0] < 0:
f = "-"
else:
o += a[i-1]
... |
s361240274 | p03739 | u626217906 | 1587509763 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2110 | 137912 | 861 | n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(n):
if i == 0:
if a[0] > 0:
f = "+"
elif a[0] < 0:
f = "-"
else:
if f == "+":
if a[i] + sum(a[:i]) > 0:
c = -1 - sum(a[:i])
ans += abs(c - a[i])... |
s993552392 | p03739 | u496821919 | 1587418200 | Python | Python (3.4.3) | py | Runtime Error | 43 | 14468 | 518 | n = int(input())
a = list(map(int,input().split()))
S1 = 0
S2 = 0
#S1が奇数番目が正の場合、S2が偶数番目が負の場合
cnt = 0
for i,num in enumerate(a):
S1 += num
if i % 2 == 0 and S1 <= 0:
cnt1 += 1 - S1
S1 = 1
if i % 2 != 0 and S1 >= 0:
cnt1 += 1 + S1
S1 = -1
S2 += num
if i % 2 == 0 and ... |
s987259186 | p03739 | u931173291 | 1587005990 | Python | Python (3.4.3) | py | Runtime Error | 81 | 14468 | 522 | n=int(input())
a=list(map(int,input().split()))
sum=0
cnt=0
# 奇数+
for i in range(n):
sum+=a[i]
if i%2==0:
if sum>=0:
cnt+=(sum+1)
sum=-1
else:
if sum<=0:
cnt+=(1-sum)
sum=1
cnt_sbst=cnt
# 奇数-
cnt=0
sum=0
for i in range(n):
z+=a[i]
if i%... |
s383450010 | p03739 | u931173291 | 1587005395 | Python | Python (3.4.3) | py | Runtime Error | 43 | 14468 | 542 | n=int(input())
a=list(map(int,input().split()))
import sys
sum=0
cnt=0
# 奇数+
for i in range(n):
z+=a[i]
if i%2==0:
if z<0:
sum=z
else:
cnt+=(z+1)
sum=-1
else:
if sum<=0:
cnt+=(1-sum)
sum=1
cnt_sbst=cnt
# 奇数-
for i in range(n... |
s255582063 | p03739 | u609061751 | 1584158247 | Python | PyPy3 (2.4.0) | py | Runtime Error | 238 | 59248 | 1066 | import sys
input = sys.stdin.readline
n = int(input())
a = [int(x) for x in input().split()]
# スタート+
if a[0] <= 0:
A1 = 1
ans1 += abs(a[0]) + 1
else:
A1 = a[0]
ans1 = 0
for i in range(1, n):
nextA = A1 + a[i]
if (A1 > 0 and nextA < 0) or (A1 < 0 and nextA > 0):
A1 = nextA
elif next... |
s603559040 | p03739 | u609061751 | 1584158164 | Python | PyPy3 (2.4.0) | py | Runtime Error | 237 | 59120 | 1041 | import sys
input = sys.stdin.readline
n = int(input())
a = [int(x) for x in input().split()]
# スタート+
if a[0] <= 0:
A1 = 1
ans1 += abs(a[0]) + 1
else:
A1 = a[0]
for i in range(1, n):
nextA = A1 + a[i]
if (A1 > 0 and nextA < 0) or (A1 < 0 and nextA > 0):
A1 = nextA
elif nextA == 0 and A1... |
s288012996 | p03739 | u854612823 | 1583445763 | Python | Python (3.4.3) | py | Runtime Error | 46 | 14332 | 403 | n = input()
a = [int(i) for i in input().split()]
cou = len(a)
counter = 0
X = a[0]
ans = 0
for i in a:
if X > 0:
b = -1 - X
ans += abs(b - a[i])
X = -1
counter += 1
if counter == cou - 1:
break
else:
b = 1 - X
ans += abs(b - a[i])
X = ... |
s051200063 | p03739 | u854612823 | 1583441592 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 209 | n = input()
a = [int(i) for i in input.split()]
X = 0
ans = 0
for i in a:
X += i
if X > 0:
b = -1 - X
ans += b - a[i+1]
else:
b = 1 - X
ans += b - a[i+1]
print (ans) |
s934153849 | p03739 | u854612823 | 1583440881 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 219 | n = input()
a = [int(i) for i in input.split()]
X = 0
ans = 0
for i in a:
X += i
if X > 0:
b = -1 - X
ans += b - a(i+1)
else X < 0:
b = 1 - X
ans += b - a(i+1)
return ans
print (ans) |
s601693471 | p03739 | u854612823 | 1583440816 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 219 | n = input()
a = [int(i) for i in input.solit()]
X = 0
ans = 0
for i in a:
X += i
if X > 0:
b = -1 - X
ans += b - a(i+1)
else X < 0:
b = 1 - X
ans += b - a(i+1)
return ans
print (ans) |
s965425617 | p03739 | u127499732 | 1580675333 | Python | Python (3.4.3) | py | Runtime Error | 106 | 14332 | 193 | n=int(input())
l=list(map(int,input().split()))
c,f=0,l[0]/abs(l[0])
s=l[0]
for i in range(1,n):
t=s+l[i]
if s*t>=0:
s=-1*f
c+=abs(t)+1
else:
f=-1*f
s=s+l[i]
print(int(c)) |
s749782194 | p03739 | u127499732 | 1580674892 | Python | Python (3.4.3) | py | Runtime Error | 106 | 14332 | 196 | n=int(input())
l=list(map(int,input().split()))
c,f=0,l[0]/abs(l[0])
s=l[0]
for i in range(1,n,1):
t=s+l[i]
if s*t>0:
s=-1*f
c+=abs(t-s+1)
else:
f=-1*f
s=s+l[i]
print(int(c)) |
s356297779 | p03739 | u462329577 | 1580652216 | Python | Python (3.4.3) | py | Runtime Error | 141 | 14644 | 995 | #!/usr/bin/env python3
n = int(input())
a = list(map(int,input().split()))
cnt = 0
current_sum = a[0]#現在の操作後の値
# 正負どちらを起点にするかで2通り考える必要がある。
# a[0]に従うパターン
for i in range(n-1):
if current_sum * (current_sum + a[i+1]) < 0:#符号が違う
current_sum += a[i+1]
cnt += 0#そのまま
elif current_sum < 0:
cnt +... |
s812565026 | p03739 | u779455925 | 1580180294 | Python | PyPy3 (2.4.0) | py | Runtime Error | 248 | 64112 | 523 | # input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
# import functools
# import itertools
# import math
n=int(input())
A=list(map(int,input().split()))
temp=A[0]
if temp<0:
flag=0
if temp>0:
flag=1
count=0
for i in range(1,n):
temp+=A[i]
if flag:
... |
s165903948 | p03739 | u379959788 | 1579803085 | Python | PyPy3 (2.4.0) | py | Runtime Error | 164 | 38384 | 1135 | import numpy as np
N = int(input())
A = list(map(int, input().split()))
res_plus = np.cumsum(A)
res_minus = np.cumsum(A)
ans_plus = 0
ans_minus = 0
tmp_tmp = 0
# 奇数項を正とする
for i in range(N):
res_plus[i] += tmp_tmp
if i % 2 == 0: # 奇数項
if res_plus[i] > 0:
pass
else:
... |
s435146592 | p03739 | u875600867 | 1579750951 | Python | Python (3.4.3) | py | Runtime Error | 1329 | 142756 | 1242 | n = int(input())
a = list(map(int, input().split()))
cnt=0
for i in range(1,n):
# 条件満たすまでループ
for _ in range(3):
print(a)
now_tmp = sum(a[:i])
next_tmp = sum(a[:i+1])
print(i, now_tmp, next_tmp)
# 符号が逆転していればOK かつ 現在までの総和が0でない
# 異なる符号を掛けるとマイナスにな... |
s748792913 | p03739 | u875600867 | 1579750920 | Python | Python (3.4.3) | py | Runtime Error | 1316 | 143064 | 1240 | n = int(input())
a = list(map(int, input().split()))
cnt=0
for i in range(1,n):
# 条件満たすまでループ
for _ in range(3):
print(a)
now_tmp = sum(a[:i])
next_tmp = sum(a[:i+1])
print(i, now_tmp, next_tmp)
# 符号が逆転していればOK かつ 現在までの総和が0でない
# 異なる符号を掛けるとマイナスにな... |
s225883441 | p03739 | u875600867 | 1579750670 | Python | Python (3.4.3) | py | Runtime Error | 1328 | 142736 | 1240 | n = int(input())
a = list(map(int, input().split()))
cnt=0
for i in range(1,n):
# 条件満たすまでループ
for _ in range(3):
print(a)
now_tmp = sum(a[:i])
next_tmp = sum(a[:i+1])
print(i, now_tmp, next_tmp)
# 符号が逆転していればOK かつ 現在までの総和が0でない
# 異なる符号を掛けるとマイナスにな... |
s909431484 | p03739 | u875600867 | 1579750522 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 142792 | 1231 | n = int(input())
a = list(map(int, input().split()))
cnt=0
for i in range(1,n):
# 条件満たすまでループ
while True:
print(a)
now_tmp = sum(a[:i])
next_tmp = sum(a[:i+1])
print(i, now_tmp, next_tmp)
# 符号が逆転していればOK かつ 現在までの総和が0でない
# 異なる符号を掛けるとマイナスになる
... |
s303864810 | p03739 | u993435350 | 1579736297 | Python | Python (3.4.3) | py | Runtime Error | 1796 | 139524 | 619 | N = int(input())
A = list(map(int,input().split()))
totals = [0] * N
totals[0] = A[0]
con = 0
if totals[0] == 0:
for i in range(1,N):
if A[i] != 0:
f = A[i]
if f > 0:
totals[0] = -1
else:
totals[0] = 1
break
else:
totals[0] = 1
con += 1
for i in range(1,N):
total... |
s716866408 | p03739 | u912115033 | 1579579629 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 369 | a = list(map(int,input().split()))
if a[0] > 0:
f = 1
else:
f = -1
m = a[0]
cnt = 0
for i in range(1, n):
f *= -1
m += a[i]
if f == 1:
if m > 0:
continue
else:
cnt += f-m
m += f-m
else:
if m < 0:
continue
else:
... |
s257047207 | p03739 | u062189367 | 1579325474 | Python | PyPy3 (2.4.0) | py | Runtime Error | 235 | 63444 | 667 | n = int(input())
a = list(int(i) for i in input().split())
b = []
for i in range(0,len(a)):
b.append(a[i])
def solve(cnt,A,N):
for i in xrange(1, N):
if sum(A[0:i])>0:
if sum(A[0:i+1])>=0:
r = A[i]
A[i]=-sum(A[0:i])-1
cnt+=abs(r-A[i])
... |
s959975122 | p03739 | u121921603 | 1578957617 | Python | PyPy3 (2.4.0) | py | Runtime Error | 183 | 38384 | 349 | import sys
input = sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
v=[]
for s in (1,-1):
x=a[::]
hugou=[s*(-1)**i sor i in range(n)]
total=0
for i in range(n):
if (total+x[i])*hugou[i]<=0:
x[i]=hugou[i]-total
total+=xs[i]
v.append(sum(absa[i]-x[i])for ... |
s063200374 | p03739 | u933341648 | 1578682073 | Python | Python (3.4.3) | py | Runtime Error | 164 | 14332 | 295 | n = int(input())
a = [int(x) for x in input().split()]
res = 0
x = 0
for i in range(n-1):
x += a[i]
sign = (x // abs(x)) * (-1)
tmp = sign - (x + a[i+1])
if sign < 0:
tmp = min(tmp, 0)
else:
tmp = max(tmp, 0)
res += abs(tmp)
a[i+1] += tmp
print(res) |
s880765112 | p03739 | u968404618 | 1578649896 | Python | Python (3.4.3) | py | Runtime Error | 42 | 14332 | 531 | def main():
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
def Chk(a, pos):
cnt = 0
tmp = 0
for a in A:
tmp += a
if pos and tmp < 1:
cnt += 1 - tmp
tmp = 1
elif ... |
s452218933 | p03739 | u968404618 | 1578649689 | Python | PyPy3 (2.4.0) | py | Runtime Error | 225 | 63088 | 381 | n = input()
A = list(map(int, input().split()))
def Chk(a, pos):
cnt = 0
tmp = 0
for a in A:
tmp += a
if pos and tmp < 1:
cnt += 1 - tmp
tmp = 1
elif not pos and tmp > -1:
cnt += 1 + tmp
tmp = -1
pos = no... |
s898776002 | p03739 | u968404618 | 1578645364 | Python | Python (3.4.3) | py | Runtime Error | 43 | 15100 | 559 | def main():
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
A = ()
A_append = A.append
cnt = 0
for i in range(n-1):
A_append(a[i])
x = sum(A) + a[i+1]
if sum(A) > 0 and x > 0:
y = abs(x)+1
cnt +=... |
s652107092 | p03739 | u223646582 | 1577746211 | Python | Python (3.4.3) | py | Runtime Error | 46 | 14468 | 514 | n = int(input())
L = [[int(i) for i in input().split()], [-int(i) for i in input().split()]]
c = 10**15
for i in range(2):
A = L[i]
if A[0] != 0:
ans = 0
S = A[0]
f = A[0]//abs(A[0])
else:
ans = 1
S = 1
f = 1
for a in A[1:]:
S += a
if S =... |
s225611515 | p03739 | u223646582 | 1577744846 | Python | Python (3.4.3) | py | Runtime Error | 106 | 14468 | 618 | n = int(input())
A = [int(i) for i in input().split()]
ff = -1
for i in range(n):
if A[i] != 0:
ff = i
break
if A[0] != 0:
ans = 0
S = A[0]
f = A[0]//abs(A[0])
else:
if ff == -1:
ans = 1
S[0] = 1
f = 1
else:
if ff % 2 == 0:
ans = 1
... |
s047173337 | p03739 | u484229314 | 1577635300 | Python | Python (3.4.3) | py | Runtime Error | 187 | 14468 | 554 | N = int(input())
A = [int(_) for _ in input().split()]
ans = 0
s = A[0]
i = 1
while i < N:
a = A[i]
# print(i, s, ans)
sign = (s // abs(s))
abs_min = abs(s) + 1
if a == 0:
ans += abs_min
s = -sign
i += 1
continue
abs_a = abs(a)
a_sign = (a // abs_a)
i... |
s957535708 | p03739 | u095562538 | 1577083289 | Python | Python (3.4.3) | py | Runtime Error | 134 | 14332 | 1170 | # coding: utf-8
# Here your code
N = int(input())
a = [int(i) for i in input().split()]
result_1 = 0
before_sum =a[0]
after_sum =a[0]
for i in range(1,N):
before_sum = after_sum
after_sum = before_sum + a[i]
if before_sum * after_sum > 0:
if after_sum < 0:
result_1 += 1 - after_sum... |
s910986115 | p03739 | u095562538 | 1577082836 | Python | Python (3.4.3) | py | Runtime Error | 138 | 14332 | 1169 | # coding: utf-8
# Here your code
N = int(input())
a = [int(i) for i in input().split()]
result_1 = 0
before_sum =a[0]
after_sum =a[0]
for i in range(1,N):
before_sum = after_sum
after_sum = before_sum + a[i]
if before_sum * after_sum > 0:
if after_sum < 0:
result_1 += 1 - after_sum... |
s276121511 | p03739 | u905582793 | 1576872244 | Python | Python (3.4.3) | py | Runtime Error | 125 | 14468 | 1021 | # coding: utf-8
# Your code here!
n = int(input())
a = list(map(int,input().split()))
def operate(ls,x):
sm = 0
ans = 0
ans += abs(ls[0]-x)
k = x
for i in range(1,len(ls)):
sm += k
if sm > 0:
if abs(ls[i]) <= sm or sm < ls[i]:
ans += abs(ls[i]+sm+1)
... |
s294893245 | p03739 | u737321654 | 1576425179 | Python | Python (3.4.3) | py | Runtime Error | 141 | 14468 | 918 | N = int(input())
A = list(map(int, input().split()))
currentSum = 0
count3 = 0
count4 = 0
currentSum = 0
for i in range(N):
restSum = currentSum
currentSum += A[i]
if currentSum <= 0 and restSum < 0:
count3 += abs(currentSum) + 1
currentSum = 1
elif currentSum >= 0 and restSum > 0:
... |
s921382804 | p03739 | u814986259 | 1575680453 | Python | Python (3.4.3) | py | Runtime Error | 43 | 14372 | 403 | n=int(input())
a=list(map(int,input().split()))
ans=0
tmp=0
for i in range(N):
tmp+=a[i]
if i%2==0:
if tmp<=0:
ans+=abs(tmp)+1
tmp=1
else:
if tmp>=0:
ans+=abs(tmp)+1
tmp=-1
tmp=0
tmp2=0
for i in range(N):
tmp+=a[i]
if i %2==0:
if tmp>=0:
tmp2+=abs(tmp)+1
tmp=-1... |
s648905803 | p03739 | u703442202 | 1575251724 | Python | Python (3.4.3) | py | Runtime Error | 93 | 14468 | 705 | n = int(input())
a_list = list(map(int,input().split()))
def greeed(sum_a,now_a,next_a,count):
if now_a >= 0 and next_a >= 0:
next_a = -1
count += next_a + 1
elif now_a < 0 and next_a <0:
next_a = 0
count += next_a
if sum_a + next_a ==0:
if next_a >=0:
next_a += 1
count += 1
el... |
s769489160 | p03739 | u223904637 | 1574474256 | Python | PyPy3 (2.4.0) | py | Runtime Error | 177 | 38384 | 443 | n=int(input())
l=list(map(int,input().split()))
l.append(0)
a1=0
b1=0
a2=0
b2=0
for i in range(n):
b1+=l[i]
b2+=l[i]
if i%2==0:
if b1>=0:
a1+=abs(-1-b1)
b1=-1-l[i+1]
if b2=<0:
a2+=abs(1-b2)
b2=1-l[i+1]
else:
if b1<=0:
a1... |
s995356544 | p03739 | u214434454 | 1574053898 | Python | PyPy3 (2.4.0) | py | Runtime Error | 223 | 63216 | 754 | n = int(input())
a = list(map(int, input().split()))
a2 = a.copy()
ans1 = 0 #偶数インデックスが正
for i in range(n):
s1 = sum(a[:i+1])
if i % 2 == 0:
if s1 <= 0:
x = abs(s1) + 1
ans1 += x
a[i] += x
else:
continue
else:
if s1 >= 0:
x ... |
s907222240 | p03739 | u846634344 | 1573803188 | Python | PyPy3 (2.4.0) | py | Runtime Error | 220 | 63216 | 800 | def decision(i):
sum_for_i = sum(A[:i+1]) # 0~i までの sum
sum_before_i = sum(A[:i]) # 0~i-1までの sum
if sum_for_i == 0:
if sum_before_i <0:
return 1
if sum_before_i >0:
return 2
if sum_before_i > 0 and sum_for_i >0:
return 3
if sum_before_i < 0 and sum_for... |
s006012773 | p03739 | u134712256 | 1572643514 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 483 | n = int(input())
a = [int(i) for i in input().split()]
s0 = a[0]
count=0
i=0
while a[i]!=0and i!=n-1:i++
if a[i]>0:
s0+=1
count+=1
else:
s0-=1
count+=1
for i in range(1,n):
s1 = s0+a[i]
if s0*s1>=0:
if s1>0:
a[i]-=(abs(s1)+1)
count+=(abs(s1)+1)
elif s1<0:
a[i]+=(abs(s1)+1)
... |
s183441698 | p03739 | u134712256 | 1572643433 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 473 | n = int(input())
a = [int(i) for i in input().split()]
s0 = a[0]
count=0
i=0
while a[i]!=0:i++
if a[i]>0:
s0+=1
count+=1
else:
s0-=1
count+=1
for i in range(1,n):
s1 = s0+a[i]
if s0*s1>=0:
if s1>0:
a[i]-=(abs(s1)+1)
count+=(abs(s1)+1)
elif s1<0:
a[i]+=(abs(s1)+1)
count... |
s603603842 | p03739 | u626468554 | 1571778650 | Python | Python (3.4.3) | py | Runtime Error | 91 | 14468 | 486 | n = int(input())
a = list(map(int,input().split()))
ttl = a[0]
cst = 0
if a[0]>0:
flg = 1
elif a[0]<0:
flg = -1
for i in range(1,n):
ttl += a[i]
if ttl*flg < 0:
flg *= -1
else:
if flg > 0:
memo = abs(ttl)+1
ttl -= memo
cst += memo
... |
s558581474 | p03739 | u626468554 | 1571778118 | Python | Python (3.4.3) | py | Runtime Error | 142 | 14332 | 931 | n = int(input())
a = list(map(int,input().split()))
ttl = a[0]
cst = 0
if a[0]>0:
flg = 1
elif a[0]<0:
flg = -1
for i in range(1,n):
ttl += a[i]
if ttl*flg < 0:
flg *= -1
else:
if flg > 0:
memo = abs(ttl)+1
ttl -= memo
cst += memo
... |
s953822685 | p03739 | u626468554 | 1571778076 | Python | Python (3.4.3) | py | Runtime Error | 318 | 14332 | 932 | n = int(input())
a = list(map(int,input().split()))
ttl = a[0]
cst = 0
if a[0]>0:
flg = 1
elif a[0]<0:
flg = -1
for i in range(1,n):
ttl += a[i]
if ttl*flg < 0:
flg *= -1
else:
if flg > 0:
memo = abs(ttl)+1
ttl -= memo
cst += memo
... |
s358070668 | p03739 | u690781906 | 1569847039 | Python | Python (3.4.3) | py | Runtime Error | 104 | 14464 | 715 | n = int(input())
a = list(map(int, input().split()))
ans = 0
if a[0] > 0:
op = "+"
elif a[0] < 0:
op = "-"
elif a[0] == 0:
ans += 1
if a[1] > 0:
a[0] = -1
else:
a[0] = 1
total = a[0]
for i in range(1, n):
if (total+a[i]) >= 0 and op == "+":
ans += abs((-1 - total) - a[i... |
s938825250 | p03739 | u780962115 | 1569253875 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 1103 | n=int(input())
N=list(map(int,input().split()))
emptylists=[]
number=0
for i in range(n):
number+=N[i]
emptylists.append(number)
ans1=0
use=0
for i in range(n):
#偶数番が正、奇数番が負の時
if i%2==0:
#奇数番め
if emptylists[i]+use<0:
continue
if emptylists[i]+use>=0:
ans1+=em... |
s996107116 | p03739 | u785470389 | 1568872890 | Python | Python (3.4.3) | py | Runtime Error | 85 | 14468 | 482 | n = int(input())
a = [] * n
a = list(map(int, input().split()))
if a[0] > 0:
symbol = "plus"
elif a[0] < 0:
symbol = "minus"
sum1 = a[0]
count = 0
for i in range(1, n):
sum1 += a[i]
if symbol == "plus" and sum1 >= 0:
operation = sum1 + 1
count += operation
sum1 = -1
elif symbol == "minus" and sum1... |
s849966254 | p03739 | u785470389 | 1568872614 | Python | Python (3.4.3) | py | Runtime Error | 90 | 14468 | 494 | n = int(input())
a = [] * n
a = list(map(int, input().split()))
if a[0] > 0:
symbol = "plus"
elif a[0] < 0:
symbol = "minus"
sum1 = a[0]
count = 0
for i in range(1, n):
sum1 += a[i]
if symbol == "plus" and sum1 >= 0:
operation = sum1 + 1
count += operation
sum1 -= operation
elif symbol == "minus" ... |
s687616069 | p03739 | u266874640 | 1568342487 | Python | PyPy3 (2.4.0) | py | Runtime Error | 186 | 38384 | 863 | import numpy as np
import copy
N = int(input())
a = list(map(int,input().split()))
a = np.cumsum(a)
ans1 = 0
ans2 = 0
b = copy.copy(a)
for i in range(N):
if i % 2 == 0:
if a[i] > 0:
pass
else:
ans1 += abs(a[i]) + 1
a[i+1:] = list(map(lambda n:n+abs(a[i])+1, a[i+1... |
s679455493 | p03739 | u009348313 | 1568255994 | Python | PyPy3 (2.4.0) | py | Runtime Error | 169 | 38256 | 353 | N = int(input())
A = list(map(int,input().split()))
ans = 0
s = A[0]
if s > 0:
flag = 1
elif s < 0:
flag = -1
elif if A[1] < 0:
flag = 1
ans += 1
else:
flag = -1
ans += 1
for i in range(1,N):
s += A[i]
if flag == 1 and s >= 0:
ans += s + 1
s = -1
elif flag == -1 and s <= 0:
ans += 1 - s
... |
s076174967 | p03739 | u413165887 | 1567139532 | Python | Python (3.4.3) | py | Runtime Error | 42 | 14332 | 1339 | n = int(input())
a = list(map(int, input().split(' ')))
result = 0
h = 0
if a[0] == 0:
counter += 1
result += 1
else:
counter += a[0]
for i in range(1, n):
if counter < 0:
counter += a[i]
if counter == 0:
counter += 1
result +=1
elif counter > 0:
... |
s150289134 | p03739 | u271934630 | 1566960948 | Python | Python (3.4.3) | py | Runtime Error | 51 | 14332 | 357 | n = int(input())
a = [int(x) for x in input().split()]
def check(a, t):
ans = 0
x = 0
for i in a:
x += i
if t == True and x < 1:
ans += 1 - x
x = 1
elif t == False and x > -1:
ans += x + 1
x = -1
t = not t
return ans
pri... |
s002001444 | p03739 | u271934630 | 1566960874 | Python | PyPy3 (2.4.0) | py | Runtime Error | 222 | 63216 | 357 | n = int(input())
a = [int(x) for x in input().split()]
def check(a, t):
ans = 0
x = 0
for i in a:
x += i
if t == True and x < 1:
ans += 1 - x
x = 1
elif t == False and x > -1:
ans += x + 1
x = -1
t = not t
return ans
pri... |
s749388315 | p03739 | u076917070 | 1566875771 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 1024 | import sys
input=sys.stdin.readline
input = open(sys.argv[1], "r").readline
def main():
N = int(input())
A = list(map(int, input().split()))
tmp = A.copy()
mi = -1
for j in range(2):
A = tmp.copy()
s = 0
n = 0
if j == 0: # 偶数番目までの和が正 ⇒ A[0] を負にする
if A[0] ... |
s722958886 | p03739 | u450904670 | 1566779082 | Python | PyPy3 (2.4.0) | py | Runtime Error | 229 | 63216 | 723 | n = int(input())
a = list(map(int, input().split()))
import numpy as np
na = np.array(a).cumsum()
cnt = 0
if(na[0] > 0):
for i in range(n):
delta = abs(na[i]) + 1
if(i % 2 == 0 and na[i] <= 0):
cnt = cnt + delta
for j in range(i, n):
na[j] += delta
elif(i % 2 == 1 and na[i] >= 0):
... |
s227577833 | p03739 | u677523557 | 1564703047 | Python | Python (3.4.3) | py | Runtime Error | 101 | 14468 | 562 | N = int(input())
A = list(map(int, input().split()))
def count(s):
ans = 0
for i, a in enumerate(A):
if i == 0:
continue
if s < 0:
if 1-s-a >= 0:
ans += 1-s-a
s = 1
else:
s += a
elif s > 0:
i... |
s927040097 | p03739 | u201660334 | 1564203798 | Python | Python (3.4.3) | py | Runtime Error | 98 | 14332 | 261 | n = int(input())
a = list(map(int, input().split()))
count = 0
sum_a = a[0]
for i in range(n - 1):
sum_a2 = sum_a + a[i + 1]
if sum_a * sum_a2 >= 0:
count += abs(sum_a2) + 1
sum_a2 = - abs(sum_a) // sum_a
sum_a = sum_a2
print(count) |
s593519625 | p03739 | u413019025 | 1562799464 | Python | Python (3.4.3) | py | Runtime Error | 123 | 14468 | 1136 | #!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)
def read_h(typ=int):
return list(map(typ, input().split()))
def read_v(n, m=1, typ=int):
return [read_h() if m > 1 else typ(input()) for _ in range(n)]
def calc_num_op(cumul, a):
assert cumul != 0
tmp_cumul = cumul + a
# print('... |
s500685212 | p03739 | u633914031 | 1562652468 | Python | Python (3.4.3) | py | Runtime Error | 175 | 14332 | 956 | n=int(input())
b=list(map(int,input().split()))
a=b[:]
condition=''
cnt=0
wa=0
for i in range(n):
wa+=a[i]
if i == 0:
if a[i]>0:
condition='minus'
else:
condition='plus'
elif condition == 'plus':
condition='minus'
if wa<=0:
cnt+=abs(wa)+1
a[i]+=abs(wa)+1
wa+=abs(wa)+1... |
s874806197 | p03739 | u633914031 | 1562651993 | Python | Python (3.4.3) | py | Runtime Error | 185 | 14332 | 951 | n=int(input())
b=list(map(int,input().split()))
a=b[:]
condition=''
cnt=0
wa=0
for i in range(n):
wa+=a[i]
if i == 0:
if a[i]>0:
condition='minus'
else:
condition='plus'
elif condition == 'plus':
condition='minus'
if wa<=0:
cnt+=abs(wa)+1
a[i]+=abs(wa)+1
wa+=abs(wa)+1... |
s440630749 | p03739 | u633914031 | 1562651760 | Python | Python (3.4.3) | py | Runtime Error | 264 | 14332 | 935 | n=int(input())
b=list(map(int,input().split()))
a=b[:]
condition=''
cnt=0
wa=0
for i in range(n):
wa+=a[i]
if i == 0:
if a[i]>0:
condition='minus'
else:
condition='plus'
elif condition == 'plus':
condition='minus'
if wa<=0:
cnt+=abs(wa)+1
a[i]+=abs(wa)+1
wa+=abs(wa)+1... |
s442277787 | p03739 | u633914031 | 1562651343 | Python | Python (3.4.3) | py | Runtime Error | 259 | 14084 | 929 | n=int(input())
b=list(map(int,input().split()))
a=b
condition=''
cnt=0
wa=0
for i in range(n):
wa+=a[i]
if i == 0:
if a[i]>0:
condition='minus'
else:
condition='plus'
elif condition == 'plus':
condition='minus'
if wa<=0:
cnt+=abs(wa)+1
a[i]+=abs(wa)+1
wa+=abs(wa)+1
... |
s673797089 | p03739 | u416773418 | 1560800292 | Python | Python (3.4.3) | py | Runtime Error | 141 | 14468 | 381 | n=int(input())
a=list(map(int,input().split()))
sm=a[0]
ans=[0, 0]
for i in range(n-1):
sm1=sm+a[i+1]
if sm*sm1>=0:
ans[0]+=abs(sm1)+1
sm//=abs(sm)*(-1)
else:
sm=sm1
sm=-1
ans[1]+=abs(a[0])+1
for i in range(n-1):
sm1=sm+a[i+1]
if sm*sm1>=0:
ans[1]+=abs(sm1)+1
... |
s155523434 | p03739 | u416773418 | 1560800015 | Python | Python (3.4.3) | py | Runtime Error | 89 | 14332 | 207 | n=int(input())
a=list(map(int,input().split()))
sm=a[0]
ans=0
for i in range(n-1):
sm1=sm+a[i+1]
if sm*sm1>=0:
ans+=abs(sm1)+1
sm//=abs(sm)*(-1)
else:
sm=sm1
print(ans) |
s241831298 | p03739 | u463655976 | 1559996395 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 199 | N = input()
a = map(int, input().split())
def f(x):
cnt = 0
cur = 0
for ai in a:
cur += ai
cur *= x
if cur < 0:
cnt += 1 - ai
x *= -1
print(cnt)
print(min(f(1), f(-1)) |
s895794717 | p03739 | u551909378 | 1558986785 | Python | Python (3.4.3) | py | Runtime Error | 195 | 14468 | 799 | N = int(input())
a = [int(x) for x in input().split()]
A = a[0]
asum = [A]
if A == 0:
ansp,ansm,tempp,tempm = 1,1,1,-1
elif A < 0:
ansp,ansm,tempp,tempm = -A + 1, 0, -A + 1, 0
else:
ansp,ansm,tempp,tempm = 0, A2 + 1, 0, -A2 - 1
for i in range(1,N):
A = asum[i-1] + a[i]
asum += [A]
A1 = A + te... |
s238424992 | p03739 | u391731808 | 1557620164 | Python | Python (3.4.3) | py | Runtime Error | 128 | 14468 | 404 | N = int(input())
*A, = map(int,input().split())
ans1 = 0
S = A[0]
if S <= 0:
S = 1
ans1 = abs(S)+1
for a in A[1:]:
S1 = S+a
if S1*S >= 0:
ans1 += abs(S1)+1
S1 = -S//abs(S)
S = S1
ans2 = 0
S = A[0]
if S >= 0:
S = -1
ans2 = abn(S)+1
for a in A[1:]:
S1 = S+a
if S1*S >= 0... |
s704420737 | p03739 | u391731808 | 1557619726 | Python | Python (3.4.3) | py | Runtime Error | 88 | 14332 | 182 | N = int(input())
*A, = map(int,input().split())
ans = 0
S = A[0]
for a in A[1:]:
S1 = S+a
if S1*S >= 0:
ans += abs(S1)+1
S1 = -S//abs(S)
S = S1
print(ans) |
s188481262 | p03739 | u059436995 | 1556332758 | Python | Python (3.4.3) | py | Runtime Error | 94 | 14332 | 329 | n = int(input())
A = list(map(int, input().split()))
cnt = 0
w = A[0]
for i in range(n - 1):
nw = w + A[i + 1]
if w > 0:
if nw >= 0:
cnt += nw + 1
chg = -(nw + 1)
else:
if nw <= 0:
cnt += 1 - nw
chg = 1 - nw
w = nw + chg
chg = 0
p... |
s255774848 | p03739 | u059436995 | 1556331183 | Python | Python (3.4.3) | py | Runtime Error | 96 | 14332 | 335 | n = int(input())
A = list(map(int, input().split()))
cnt = 0
w = A[0]
for i in range(n - 1):
nw = w + A[i + 1]
if w > 0:
if nw >= 0:
cnt += nw + 1
chg = -(nw + 1)
elif w < 0:
if nw <= 0:
cnt += 1 - nw
chg = 1 - nw
w = nw + chg
chg = 0
... |
s364009713 | p03739 | u059436995 | 1556327722 | Python | Python (3.4.3) | py | Runtime Error | 706 | 14468 | 678 | n = int(input())
A = list(map(int, input().split()))
def ssa(n):
arr = A
memo =['inf'] * (n + 1)
def _ssa(n):
if n == 0:
return arr[0]
if memo[n] != 'inf':
return memo[n]
memo[n] = _ssa(n -1) + arr[n]
return memo[n]
return _ssa(n)
cnt = 0
chg = 0... |
s347678689 | p03739 | u893132811 | 1556300502 | Python | Python (3.4.3) | py | Runtime Error | 153 | 14464 | 848 | n = int(input())
A = list(map(int, input().split()))
ans1 = 0
sum = A[0]
for a in A[1:]:
if (sum + a) * sum < 0:
sum += a
else:
fugo = sum // abs(sum)
nextsum = - fugo
#print('fugo={}, nextsum={}'.format(fugo, nextsum))
a_should_be = nextsum - sum
dif = abs(a_sho... |
s890642896 | p03739 | u893132811 | 1556299078 | Python | Python (3.4.3) | py | Runtime Error | 154 | 14468 | 727 | n = int(input())
A = list(map(int, input().split()))
ans1 = 0
sum = A[0]
for a in A[1:]:
if (sum + a) * sum < 0:
sum += a
else:
fugo = sum // abs(sum)
nextsum = - fugo
a_should_be = nextsum - sum
dif = abs(a_should_be - a)
sum += a_should_be
ans1 += dif
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.