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
s130643570
p03739
u893132811
1556298938
Python
Python (3.4.3)
py
Runtime Error
151
14468
701
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 ...
s064217281
p03739
u893132811
1556298528
Python
Python (3.4.3)
py
Runtime Error
99
14332
328
n = int(input()) A = list(map(int, input().split())) ans = 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 ans += dif pr...
s914327220
p03739
u501643136
1554945768
Python
Python (3.4.3)
py
Runtime Error
27
11516
415
n = int(input()) A = [map(int,input().split())] acm1 = 0 acm2 = 0 ans1 = 0 ans2 = 0 for i, a in enumerate(A): acm1 += a acm2 += a if(i%2==1): if(acm1>=0): ans1 += acm1 + 1 acm1 = -1 if(acm2<=0): ans2 += -acm2 + 1 acm2 = 1 else: if(acm1<=0): ans1 += -acm1 + 1 acm1 ...
s749542591
p03739
u227082700
1554840084
Python
Python (3.4.3)
py
Runtime Error
17
2940
213
n=int(input()) A=list(map(int,input().split())) ans=10**15 for i in[-1,1]: ansi,sum=0,0 for a in A: sum+=a if sum*i<=0:;ansi+=abs(sum-i);sum=i i*=-1 ans=min(ans,ansi) print(ans)
s295169193
p03739
u210827208
1554827909
Python
Python (3.4.3)
py
Runtime Error
76
14468
485
n=int(input()) X=list(map(int,input().split())) res=X[0] cnt=0 if X[0]==0: cnt=1 res=1 for i in range(1,n): if X[i]>0: tmp=i cnt+=2*(i-1) res=-1 elif X[i]<0: tmp=i cnt+=2*(i-1) res=1 for i in range(tmp,n)...
s537653860
p03739
u013408661
1554314722
Python
Python (3.4.3)
py
Runtime Error
45
14468
448
n=int(input()) p=list(map(int,input().split())) stack=[0]*(n+1) ans=0 if p[0]==0: p[0]=1 ans+=1 stack[1]=1 else: stack[1]=p[0] for i in range(1,n): if i%2==1: if p[i]+p[i-1]+stack[i-1]>=0: p[i]-=(p[i]+p[i-1]+stack[i-1])+1 ans+=(p[i]+p[i-1]+stack[i-1])+1 else: if p[i]+p[i-1]+stack[i-1]<=0...
s386000990
p03739
u536377809
1554096740
Python
Python (3.4.3)
py
Runtime Error
2104
15160
528
import copy N=int(input()) l=list(map(int, input().split())) #リスト入力 cp = copy.copy(l) #c=0 for k in range(1,N): if sum(l[:k])==0: #c=c+1 if l[k]>0: l[k]=l[k]+1 else: l[k]=l[k]-1 if sum(l[:k])*sum(l[:k+1])>0: if sum(l[:k+1])>0: l[k]=l[k]-(sum(l[:k+1])-(-1)) #c=c+...
s567314346
p03739
u536377809
1554096323
Python
Python (3.4.3)
py
Runtime Error
2104
15160
526
import copy N=int(input()) l=list(map(int, input().split())) #リスト入力 cp = copy.copy(l) #c=0 for k in range(N-1): if sum(l[:k+1])==0: #c=c+1 if l[k+1]>0: l[k+1]=l[k+1]+1 else: l[k+1]=l[k+1]-1 if sum(l[:k])*sum(l[:k+1])>0: if sum(l[:k+1])>0: l[k]=l[k]-(sum(l[:k+1])-(-1)) ...
s040910096
p03739
u536377809
1554096186
Python
Python (3.4.3)
py
Runtime Error
2104
15156
596
import copy N=int(input()) l=list(map(int, input().split())) #リスト入力 cp = copy.copy(l) #c=0 for k in range(N-1): if sum(l[:k+1])==0: #c=c+1 if l[k+1]>0: l[k+1]=l[k+1]+1 else: l[k+1]=l[k+1]-1 if sum(l[:k])*sum(l[:k+1])>0: print(k,sum(l[:k]),sum(l[:k+1]),l[k+1]) if sum(l[:k+1])>0: ...
s550987859
p03739
u151625340
1554050557
Python
Python (3.4.3)
py
Runtime Error
100
14332
297
n = int(input()) a = list(map(int,input().split())) s = 0 sign = a[0]//abs(a[0]) ans = 0 for i in range(n): s += a[i] if s == 0: s = sign ans += 1 elif s//abs(s) == sign: pass else: ans += abs(sign-s) s = sign sign *= -1 print(ans)
s561200151
p03739
u807772568
1552433079
Python
Python (3.4.3)
py
Runtime Error
107
14468
512
n = int(input()) a = list(map(int,input().split())) if a[0] != 0: b = [a[0]] else: su += 1 if b[1] > 0: b = [-1] else: b = [1] su = 0 for i in range(n-1): b.append(b[-1]+a[1+i]) if b[-1] * b[-2] > 0: su += abs(b[-1]) + 1 if b[-2] > 0: b[-1] = -1 ...
s745417899
p03739
u239981649
1549176471
Python
Python (3.4.3)
py
Runtime Error
294
14468
545
n = int(input()) *a, = map(int, input().split()) if a[0]: ans = 0 e0 = 1 if a[0] > 0 else -1 S = a[0] for i in range(1, n): e = e0 * int((i % 2-0.5)*2) n = max(e*(S+a[i])+1, 0) S += a[i]+(-e*n) ans += n print(ans) else: ans = [0, 0] for e0 in [1, -1]: ...
s397029644
p03739
u189575640
1548111025
Python
Python (3.4.3)
py
Runtime Error
1333
142824
440
import sys n = int(input()) a = [int(n) for n in input().split()] sum = [0]*n sum[0] = a[0] ans = 0 for i in range(1,n): sum[i] = sum[i-1] while((sum[i]+a[i])*sum[i-1] >= 0): if(sum[i-1] > 0): ans+=sum[i-1] + a[i]+1 a[i]-=sum[i-1] + a[i]+1 else: ans+=1 - sum[i...
s635155765
p03739
u138486156
1544663531
Python
Python (3.4.3)
py
Runtime Error
2104
14332
834
n = int(input()) a = list(map(int, input().split())) not_0 = n for i in range(n): if a[i]: not_0 = i break if not_0 == n: print(1+2*(n-1)) exit() ans = 0 if not_0 == 0: b = [a[0]] else: if abs(a[not_0]) == 1: a[not_0] *= 2 ans = 2*not_0 else: ans = 1 + ...
s755290655
p03739
u166696759
1541981905
Python
Python (3.4.3)
py
Runtime Error
2104
14468
486
n = int(input()) A = [item for item in list(map(int, input().split()))] S = [A[0]] for i in range(1, n): S.append(A[i]+S[i-1]) count = 0 if S[0] == 0: A[0] += 1 for item in S: item += 1 count += 1 #print(S) for i in range(1, n): #print(S[i-1], S[i]) if S[i] * S[i-1] >= 0: dif = ...
s347168922
p03739
u404676457
1541371674
Python
Python (3.4.3)
py
Runtime Error
84
14376
591
def culc(a, sum, plus, ans): for i in range(1, n): plus = not(plus) sum += a[i] if plus: if sum <= 0: ans += abs(sum) + 1 sum = 1 else: if sum >= 0: ans += abs(sum) + 1 sum = -1 return ans n...
s666598927
p03739
u404676457
1541371196
Python
Python (3.4.3)
py
Runtime Error
123
14468
738
n = int(input()) a = list(map(int, input().split())) sum = a[0] plus = None if a[0] > 0: plus = True else: plus = False ans1 = 0 for i in range(1, n): plus = not(plus) sum += a[i] if plus: if sum <= 0: ans1 += abs(sum) + 1 sum = 1 else: if sum >= 0: ...
s194781410
p03739
u883048396
1540957506
Python
Python (3.4.3)
py
Runtime Error
17
3064
690
def 解() iN = int(input()) aA = [int(_) for _ in input().split()] iL = len(aA) iStart = 0 if sum(aA[0::2]) < sum(aA[2::2]): iStart = 1 iC = 0 aD = [0]*iL if 0 % 2 == iStart : if aA[0] < 0: aA[0] = 1 iC += -1 * aA[0] + 1 else: if 0 < ...
s283612901
p03739
u853900545
1539389913
Python
Python (3.4.3)
py
Runtime Error
147
14468
400
n = int(input()) a = list(map(int,input().split())) cnt = 0 sum = [0]*n sum[0] = a[0] for i in range(1,n): sum[i] = sum[i-1]+a[i] if sum[i]*sum[i-1]<0: continue elif sum[i-1]*a[i]<0: cnt += abs(sum[i-1])-abs(a[i])+1 sum[i] = -1*(sum[i-1]//abs(sum[i-1])) else: cnt += abs...
s147437373
p03739
u853900545
1539369017
Python
Python (3.4.3)
py
Runtime Error
139
14468
420
n = int(input()) a = list(map(int,input().split())) if n == 1: print(0) cnt = 0 sum = [0]*n sum[0] = a[0] for i in range(1,n): sum[i] = sum[i-1]+a[i] if sum[i]*sum[i-1]<0: continue elif sum[i-1]*a[i]<0: cnt += abs(sum[i-1])-abs(a[i])+1 sum[i] = -(sum[i-1]//abs(sum[i-1])) e...
s318462249
p03739
u853900545
1539363333
Python
Python (3.4.3)
py
Runtime Error
142
14468
395
n = int(input()) a = list(map(int,input().split())) cnt = 0 sum = [0]*n sum[0] = a[0] for i in range(1,n): sum[i] = sum[i-1]+a[i] if sum[i]*sum[i-1]<0: continue elif sum[i-1]*a[i]<0: cnt += abs(sum[i-1])-abs(a[i])+1 sum[i] = -(sum[i-1]//abs(sum[i-1])) else: cnt += abs(s...
s110202102
p03739
u853900545
1539363251
Python
Python (3.4.3)
py
Runtime Error
147
14468
391
n = int(input()) a = list(map(int,input().split())) cnt = 0 sum = [0]*n sum[0] = a[0] for i in range(1,n): sum[i] = sum[i-1]+a[i] if sum[i]*sum[i-1]<0: continue elif sum[i-1]*a[i]<0: cnt += abs(sum[i-1])-abs(a[i])+1 sum[i] = -sum[i-1]//abs(sum[i-1]) else: cnt += abs(sum...
s310033196
p03739
u853900545
1539362956
Python
Python (3.4.3)
py
Runtime Error
141
14468
389
n = int(input()) a = list(map(int,input().split())) cnt = 0 sum = [0]*n sum[0] = a[0] for i in range(1,n): sum[i] = sum[i-1]+a[i] if sum[i]*sum[i-1]<0: continue if sum[i-1]*a[i]<0: cnt += abs(sum[i-1])-abs(a[i])+1 sum[i] = -sum[i-1]//abs(sum[i-1]) else: cnt += abs(sum[i...
s540204748
p03739
u099918199
1539142339
Python
Python (3.4.3)
py
Runtime Error
256
15108
843
n = int(input()) list_a = list(map(int,input().split())) i = 0 k = 0 count = 0 ans = list_a[0] if list_a[0] > 0: for i in range(1,n): ans += list_a[i] if ans / ((-1) ** i) <= 0: count += abs(ans - (-1) ** i) ans = (-1) ** i else: for i in range(1,n): ans += list_...
s515461724
p03739
u201234972
1537920905
Python
Python (3.4.3)
py
Runtime Error
43
14332
272
N = int( input()) A = list( map( int, input().split())) ans = 10**15 for i in [1, -1]: ansi, sums = 0, 0 for a in A: sums += a if sums*i <= 0: ansi += abs(sums-s) sums = s s *= -1 ans = min( ans, ansi) print(ans)
s178550092
p03739
u201234972
1537920859
Python
Python (3.4.3)
py
Runtime Error
42
14332
272
N = int( input()) A = list( map( int, input().split())) ans = 10**15 for i in [1, -1]: ansi, sums = 0, 0 for a in A: sums += A if sums*i <= 0: ansi += abs(sums-s) sums = s s *= -1 ans = min( ans, ansi) print(ans)
s282015478
p03739
u201234972
1537920190
Python
Python (3.4.3)
py
Runtime Error
125
14332
1322
n = int( input()) A = list( map( int, input().split())) ansp = 0 sums = A[0] if sums == 0: ansp += 1 sums += 1 for i in range(1,n-1): sums += A[i] if i%2 == 1: if sums < 0: pass else: ansp += abs(-1-sums) sums = -1 else: if sums > 0: ...
s130697564
p03739
u826263061
1536442364
Python
Python (3.4.3)
py
Runtime Error
239
14468
605
# -*- coding: utf-8 -*- """ Created on Sat Sep 8 15:51:53 2018 @author: maezawa """ def f(n, a0, cnt, sa, sign): a = a0[:] if sign == -1: cnt += abs(a[0])+1 a[0] = -a[0]/abs(a[0]) for i in range(n-1): sa += a[i] na = -sa//abs(sa)*(abs(sa)+1) if abs(a[i+1]) > abs(na)...
s971762533
p03739
u826263061
1536441253
Python
Python (3.4.3)
py
Runtime Error
183
14468
597
# -*- coding: utf-8 -*- """ Created on Sat Sep 8 15:51:53 2018 @author: maezawa """ def f(n, a0, cnt, sa, sign): a = a0[:] if sign == -1: a[0] = -a[0] cnt += 2*a[0] for i in range(n-1): sa += a[i] na = -sa//abs(sa)*(abs(sa)+1) if abs(a[i+1]) > abs(na) and a[i+1]*na ...
s545347517
p03739
u826263061
1536439190
Python
Python (3.4.3)
py
Runtime Error
149
14212
368
# -*- coding: utf-8 -*- """ Created on Sat Sep 8 15:51:53 2018 @author: maezawa """ n = int(input()) a = list(map(int, input().split())) sa = 0 cnt = 0 for i in range(0,n-1): sa += a[i] na = -sa//abs(sa)*(abs(sa)+1) if abs(a[i+1]) > abs(na) and a[i+1]*na > 0: continue else: cnt += abs...
s044378831
p03739
u826263061
1536437727
Python
Python (3.4.3)
py
Runtime Error
144
14332
350
# -*- coding: utf-8 -*- """ Created on Sat Sep 8 15:51:53 2018 @author: maezawa """ n = int(input()) a = list(map(int, input().split())) sa = 0 cnt = 0 for i in range(0,n-1): sa += a[i] na = -sa//abs(sa)*(abs(sa)+1) if abs(a[i+1]) > abs(na) and a[i+1]*na > 0: continue cnt += abs(na-a[i+1]) ...
s983207983
p03739
u826263061
1536437536
Python
Python (3.4.3)
py
Runtime Error
148
14212
351
# -*- coding: utf-8 -*- """ Created on Sat Sep 8 15:51:53 2018 @author: maezawa """ n = int(input()) a = list(map(int, input().split())) sa = 0 cnt = 0 for i in range(0,n-1): sa += a[i] na = -sa//abs(sa)*(abs(sa)+1) if abs(a[i+1]) > abs(na) and a[i+1]*na >= 0: continue cnt += abs(na-a[i+1]) ...
s430608276
p03739
u820351940
1534056529
Python
Python (3.4.3)
py
Runtime Error
237
23248
618
import numpy as np input() a = list(map(int, input().split())) def calc(a): value = a[0] sign = value >= 0 result = 0 for i in a[1:]: value += i diff = 0 if sign and value >= 0: diff = value + 1 elif not sign and value < 0: diff = value - 1 ...
s314095558
p03739
u588341295
1532069003
Python
Python (3.4.3)
py
Runtime Error
81
14332
533
# -*- coding: utf-8 -*- N = int(input()) aN = list(map(int, input().split())) sum1 = aN[0] cnt = 0 if aN[0] > 0: sei = True elif aN[0] < 0: sei = False else: print("和が0なので、これはないはず") for i in range(1,N): sum1 += aN[i] if sei: if sum1 >= 0: tmp = abs(sum1) +1 cnt += ...
s768115144
p03739
u004025573
1531682578
Python
Python (3.4.3)
py
Runtime Error
88
14332
275
n=int(input()) a=list(map(int,input().split())) now=a[0] flag=abs(a[0])//a[0] c=0 #print(c,flag) for i in range(1,n): tmp=now+a[i] if not tmp*flag<0: c+=abs(flag*-1-tmp) now=flag*-1 else: now=tmp flag*=-1 #print(c,flag) print(c)
s687680694
p03739
u140251125
1531274637
Python
Python (3.4.3)
py
Runtime Error
43
14468
547
# input n = int(input()) A = list(map(int, input().split())) # 偶数番目が+ A_even = A S_even = 0 ans_even = 0 for i in range(n): if (S + A_even[i]) * ((-1) ** (i - 1)) > 0: continue ans_even += S + A_even[i] + 1 A_even[i] = (-1) ** (i - 1) - S S = (-1) ** (i - 1) # 奇数番目が+ A_odd = A S_odd = 0 ans_od...
s692878464
p03739
u006657459
1530847093
Python
Python (3.4.3)
py
Runtime Error
17
3064
567
import copy n = int(input()) a = [int(ai) for ai in input().split()] def search(a, flip=False): if flip: count = 0 a_sum = a[0] else: count = abs(a[0]) + 1 a_sum = - a[0] for ai in a[1:]: next_sum = a_sum + ai if next_sum * a_sum < 0: continue ...
s577647580
p03739
u497625442
1530845828
Python
Python (3.4.3)
py
Runtime Error
17
3064
573
n = int(input()) a = list(map(int,input().split())) def find(a): f = "+" if a[0] < 0 else "-" s = a[0] c = 0 #print((s,f,c)) for i in range(1,n): if f == "+" and s + a[i] > 0: f = "-" s = s + a[i] # print((s,f,c)) elif f == "+": c = c + abs(s + a[i])+1 f = "-" s = 1 # print((s,f,c)) elif ...
s296656060
p03739
u069838609
1524956867
Python
PyPy3 (2.4.0)
py
Runtime Error
171
38256
1657
import numpy as np n = int(input()) a_array = np.array([int(elem) for elem in input().split(' ')]) def calculate_cumulative_sum(a_array, n): cumul_sum_array = np.zeros(n, dtype=np.int32) cumul_sum_array[0] = a_array[0] for i in range(1, n): cumul_sum_array[i] = cumul_sum_array[i - 1] + a_array[i]...
s542390511
p03739
u069838609
1524956772
Python
PyPy3 (2.4.0)
py
Runtime Error
171
38640
1727
import numpy as np n = int(input()) a_array = np.array([int(elem) for elem in input().split(' ')]) def calculate_cumulative_sum(a_array, n): cumul_sum_array = np.zeros(n, dtype=np.int32) cumul_sum_array[0] = a_array[0] for i in range(1, n): cumul_sum_array[i] = cumul_sum_array[i - 1] + a_array[i]...
s898635278
p03739
u503901534
1524792284
Python
Python (3.4.3)
py
Runtime Error
2104
14468
716
n = int(input()) a = list(map(int,input().split())) b = a #1 = plus cp = 0 cm = 0 sumscp = 0 sumscm = 0 for i in range(len(a)): if i % 2 == 0: while sumscp + a[i] < 1: a[i] = a[i] + 1 cp = cp + 1 sumscp = sumscp + a[i] else: while sums + a[i] > -1: ...
s144630261
p03739
u503901534
1524792238
Python
Python (3.4.3)
py
Runtime Error
2104
14468
714
n = int(input()) a = list(map(int,input().split())) b = a #1 = plus cp = 0 cm = 0 sumscp = 0 sumscm = 0 for i in range(len(a)): if i % 2 == 0: while sumscp + a[i] < 1: a[i] = a[i] + 1 cp = cp + 1 sumscp = sumscp + a[i] else: while sums + a[i] > -1: ...
s249201666
p03739
u050428930
1524391990
Python
Python (3.4.3)
py
Runtime Error
97
14468
520
N=int(input()) s=list(map(int,input().split())) if s[0]<0: t=1 elif s[0]>0: t=-1 ss=s[0] w=0 for i in range(N-1): if t==1: if ss+s[i+1]>=t: ss=ss+s[i+1] pass else: w+=t-ss-s[i+1] ss=1 t=-1 elif t==-1: if ss+s[i+1]<=t: ...
s901568585
p03739
u417835834
1523240732
Python
Python (3.4.3)
py
Runtime Error
43
14468
887
n = int(input()) a_p = list(map(int,input().split())) a_n = a_p #positive if a[0] <= 0: counter_p = 0 for i in range(n): print(a_p,counter_p) sum_ai = sum(a_p[:i+1]) if i % 2 == 0: if sum_ai <= 0: a_p[i] += -sum_ai + 1 counter_p += -sum_ai + 1...
s279101834
p03739
u813450984
1522656534
Python
Python (3.4.3)
py
Runtime Error
17
3060
196
n, x = map(int, input().split()) l = list(map(int, input().split())) ans = 0 for i in range(1, n): if l[i] + l[i-1] > x: ans += (l[i] + l[i-1]) - x l[i] -= (l[i] + l[i-1]) - x print(ans)
s179609052
p03739
u773981351
1522300025
Python
Python (3.4.3)
py
Runtime Error
111
14464
594
def ops_needed(x, target): if abs(target - x) < abs(x): return 0 else: return target - x def count_ops(a): total_ops = 0 accum = a[0] for i in range(1, len(a)): new_accum = accum + a[i] if new_accum == 0: ops = -1 * (accum / abs(accum)) else: ...
s110603747
p03739
u773981351
1522299040
Python
Python (3.4.3)
py
Runtime Error
46
14468
798
def count_ops(a): if a[0] == 0: total_ops = 1 if a[1] < 0: accum = 1 else: accum = -1 else: total_ops = 0 accum = a[0] for i in range(1, len(a)): new_accum = accum + a[i] if (accum > 0 and new_accum > 0): ops = ops_n...
s444596699
p03739
u729707098
1521697810
Python
Python (3.4.3)
py
Runtime Error
99
14332
218
n = int(input()) a = [int(i) for i in input().split()] num,answer = a[0],0 for i in range(1,n): if num*(num+a[i]) >= 0: x = (-num)//abs(num) answer += abs((x-num)-a[i]) num = x else: num += a[i] print(answer)
s468614554
p03739
u382765539
1508307369
Python
Python (3.4.3)
py
Runtime Error
18
2940
586
#include<bits/stdc++.h> using namespace std; int main(void){ int n; cin >> n; vector<int> a(n); for(auto& it : a) cin >> it; int total = a[0]; int ans = 0; for(int i=1;i<n;i++){ if(total > 0){ if(total + a[i] >= 0) { ans += abs(-total-1 - a[i]); ...
s483311403
p03739
u343437894
1499489248
Python
Python (3.4.3)
py
Runtime Error
17
2940
381
n = int(input()) as = list(map(int, input().split(" "))) ope = 0 for i in range(0, n-1): sum_be=sum(as[:i]) sum_af=sum(as[:i+1]) if sum_be<0<sum_af or sum_af<0<sum_be: continue elif sum_be > 0: ope += as[i+1] + (sum_be+1) as[i+1] = sum_be + 1 elif sum_be < 0: ope +=...
s583979684
p03739
u004797437
1495293792
Python
Python (3.4.3)
py
Runtime Error
2105
17812
581
n = int(input()) a_list = [int(i) for i in input().split(' ')] total = [a_list[0]] counter = 0 for a in a_list[1:]: total.append(total[-1] + a) if total[0]==0: total = map(lambda n: n-int(total[1]/abs(total[1])), total) for i in range(1,n): if total[i-1]<0 and total[i]<=0: counter += abs(t...
s216682401
p03739
u667084803
1493275096
Python
Python (3.4.3)
py
Runtime Error
166
14084
833
import sys # -*- coding: utf-8 -*- # 整数の入力 n=int(input()) a=list(map(int, input().split())) b=a[:] c=a[:] # 無変更チェック if a[0]!=0: S=int(a[0]) for i in range(1,n): if S<0 and S+a[i]<=0: break elif S>0 and S+a[i]>=0: break S+=a[i] if i==n-1: print(0) sys.exit() # a[0]を1に変えた場合の計算 ...
s918834790
p03739
u021406692
1493239641
Python
Python (2.7.6)
py
Runtime Error
1794
142428
940
# -*- coding:utf-8 -*- def sign(x): if (x > 0): return 1 elif (x < 0): return -1 else: return 0 n = int(raw_input()) numlist = (raw_input()).split(' ') sumlist = [int(numlist[0])] count = 0 for i in range(1, n): sumlist.append(sumlist[i-1] + int(numlist[i])) while ((sign(sumlist[i-1]) == sign...
s781978778
p03739
u667084803
1493189253
Python
Python (3.4.3)
py
Runtime Error
27
11152
289
# -*- coding: utf-8 -*- # 整数の入力 n=int(input()) a=input().split() counter=0 S=a[0] # 出力 for i in range(1,n): S+=a[i] if S<0 and S+int(a[i])<=0: counter+=-S-int(a[i])+1 a[i]=-S+1 elif S>0 and S+int(a[i])>=0: counter+=S+int(a[i])+1 a[i]=-S-1 print(counter)
s105791154
p03739
u494209838
1492981638
Python
Python (3.4.3)
py
Runtime Error
47
14332
309
# -*- coding: utf-8 -*- n = input() a = [int(x) for x in input().split()] ans = 1e16 for s in (1, -1): res, cumsum = 0, 0 for j in range(n): cumsum += a[j] if cumsum * s <= 0: res += abs(cumsum-s) cumsum = s s *= -1 ans = min(ans, res) print(ans)
s842340794
p03739
u252228075
1492919191
Python
Python (3.4.3)
py
Runtime Error
17
3064
1300
n = int(input()) i = input() i = i.split() for item in range(len(i)): i[item] = int(i[item]) totn = 0 totp = 0 countp = 0 countn = 0 for x in range(len(i)): totp += i[x] totn += i[x] ''' if x == 0: if totp == 0: totn = -1 countn = 1 totp = 1 ...
s770763845
p03739
u252228075
1492919135
Python
Python (3.4.3)
py
Runtime Error
17
3064
1302
n = int(input()) i = input() i = i.split() for item in range(len(i)): i[item] = int(i[item]) totn = 0 totp = 0 countp = 0 countn = 0 for x in range(len(i)): totp += i[x] totn += i[x] ''' if x == 0: if totp == 0: totn = -1 countn = 1 totp = 1 ...
s308353988
p03739
u024804656
1492916216
Python
Python (3.4.3)
py
Runtime Error
17
3064
659
n = int(input()) sa = input().split() a = [0 for i in range(n)] sumeven = 0 sumodd = 0 for i,sai in enumerate(sa): a[i] = int(sai) if i % 2 == 0: sumeven += a[i] else: sumodd += a[i] ret = 0 sm = 0 for i,ai in enumerate(a): if i % 2 == 1: ret += max(-sm+1-ai,0) ...
s356316247
p03739
u374514823
1492915692
Python
Python (3.4.3)
py
Runtime Error
45
14212
864
import itertools def sign(num): if num < 0: return -1 elif num > 0: return 1 else: return 0 N = input() a_i = list(map(int, input().split())) signs = [-1,1] a_sum = 0 changes_1 = 0 for i, a in enumerate(a_i): a_sum += a if sign(a_sum) != signs[i%2]: changes += abs(...
s833876932
p03739
u374514823
1492915466
Python
Python (3.4.3)
py
Runtime Error
17
3060
973
import itertools def sign(num): if num < 0: return -1 elif num > 0: return 1 else: return 0 N = input() a_i = list(map(int, input().split())) a_sum = [a_i[0]] for i, a in enumerate(a_i[1:]): i += 1 a_sum.append(a_sum[-1]+a) signs = [1, -1] for i, sum_i in enumerate(a_sum)...
s568567916
p03739
u374514823
1492915332
Python
Python (3.4.3)
py
Runtime Error
128
14212
895
import itertools def sign(num): if num < 0: return -1 elif num > 0: return 1 else: return 0 N = input() a_i = list(map(int, input().split())) a_sum = [a_i[0]] for i, a in enumerate(a_i[1:]): i += 1 a_sum.append(a_sum[-1]+a) signs = [1, -1] for i, sum_i in enumerate(a_sum)...
s874753815
p03739
u256260242
1492915304
Python
Python (3.4.3)
py
Runtime Error
28
11140
1427
n = int(input()) l = map(int, input().split()) ll = [] for q in range(len(l)): ll.append(l[q]) print(ll) sums1 = [0] * n count1 = 0 sums1[0] = ll[0] for i in range(1, len(ll)): sums1[i] = sums1[i-1] + ll[i] if l[0] == 0: for v in range(len(sums1)): sums1 += [1] * len(sums1) count1 += 1...
s218105616
p03739
u256260242
1492915205
Python
Python (3.4.3)
py
Runtime Error
27
11140
1431
n = int(input()) l = map(int, input().split()) ll = [] for q in range(len(l)): ll.append(l[q]) print(ll) sums1 = [0] * n count1 = 0 sums1[0] = ll[0] for i in range(1, len(ll)): sums1[i] = sums1[i-1] + ll[i] if l[0] == 0: for v in range(len(sums1)): sums1 += [1] * len(sums1) count1 += 1...
s074884225
p03739
u306773664
1492915188
Python
Python (3.4.3)
py
Runtime Error
2105
19244
982
N = int(input()) prog = list(map(int,input().split())) def seq(N,prog): result = [0]*N result[0] = prog[0] for i in range(N-1): result[i+1] = result[i] + prog[i+1] if result[0] == 0: if sum(result[0]+result[1]) >= 0: result[0] -= 1 x = [-1]*(N-1) resul...
s653256995
p03739
u256260242
1492915146
Python
Python (3.4.3)
py
Runtime Error
31
11140
1427
n = int(input()) l = map(int, input().split()) ll = [] for q in range(len(l)): ll.append(l[q]) print(ll) sums1 = [0] * n count1 = 0 sums1[0] = ll[0] for i in range(1, len(ll)): sums1[i] = sums1[i-1] + ll[i] if l[0] == 0: for v in range(len(sums1)): sums1 += [1] * len(sums1) count1 += 1...
s549782171
p03739
u768951609
1492914590
Python
Python (2.7.6)
py
Runtime Error
10
2568
657
n=int(raw_input()) a=map(int,raw_input().split(' ')) p_s=a[0] c=0 for i in range(1,n): s=p_s+a[i] if s==0: if i==n-1: a[i]+=1 c+=1 else: if a[i]>=0: a[i]+=1 c+=1 ...
s671577958
p03739
u706884679
1492914138
Python
Python (3.4.3)
py
Runtime Error
21
2940
818
n = int(input()) a = list(map(int, input().split())) c = 0 i = 1 k = 1 sum = a[0] while a[i] == 0: i += 1 if a[i] > 0: if i % 2 == 1: a[0] = 1 c = 1 else: a[0] = -1 c = 1 else: if i % 2 == 1: a[0] = -1 c = 1 else: a[0] = 1 c = 1 i = 1 if a[0] > 0: while i < n: if i == 2*k-1: s...
s168665796
p03739
u374514823
1492913980
Python
Python (3.4.3)
py
Runtime Error
2105
19564
754
import itertools def sign(num): if num < 0: return -1 elif num > 0: return 1 else: return 0 N = input() a_i = list(map(int, input().split())) a_sum = [a_i[0]] for i, a in enumerate(a_i[1:]): i += 1 a_sum.append(a_sum[-1]+a) signs = [0, 0] changes = 0 for i, sum_i in enum...
s046653556
p03740
u814419162
1601293305
Python
PyPy3 (7.3.0)
py
Runtime Error
86
74764
96
a,b=[int(x) for x in input().split()] if abs(a-b)<=1: print("Brown"): else: print("Alice")
s561169296
p03740
u814419162
1601293255
Python
PyPy3 (7.3.0)
py
Runtime Error
92
68656
96
a,b=[int(x) for x in input().split()] if abs(a-b)<=1: print("Brown): else: print("Alice")
s025791247
p03740
u612975321
1599090674
Python
Python (3.8.2)
py
Runtime Error
26
9004
95
x, y = = map(int,input().split()) if abs(x-y) < 1: print('Brown') else: print('Alice')
s831378099
p03740
u075595666
1595723770
Python
Python (3.8.2)
py
Runtime Error
25
9100
88
n,m = map(int(input().split())) if abs(n-m) < 2: print('Brown') else: print('Alice')
s466021731
p03740
u353797797
1579801466
Python
Python (3.4.3)
py
Runtime Error
1253
581860
1004
import sys sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(ro...
s756889287
p03740
u863044225
1578362880
Python
Python (3.4.3)
py
Runtime Error
18
2940
82
x,y=map(int,input.split()) if abs(x-y)<=1: print('Blown') else: print('Alice')
s325741153
p03740
u329706129
1575940222
Python
Python (3.4.3)
py
Runtime Error
17
2940
73
x, y = input().split() print('Alice') if (x + y) > 1 else print('Brown')
s669088843
p03740
u038815010
1575136385
Python
PyPy3 (2.4.0)
py
Runtime Error
171
38284
116
x, y = map(int, input().split()) if abs(x - y) <= 1: print('Brown') else: print('Alice')
s720192774
p03740
u143278390
1575070551
Python
Python (3.4.3)
py
Runtime Error
18
2940
90
x=int(input()) y=int(input()) if(abs(x-y)<=1): print('Brown') else: print('Alice')
s501485440
p03740
u886747123
1570347906
Python
PyPy3 (2.4.0)
py
Runtime Error
314
46576
1175
X, Y = map(int, input().split()) # 最終状態は(0,1), (1,1)のいずれか # 最終状態の1手前は勝ち確状態、その1手前は負け確状態 # 1手前に戻すには片方の山からi個石を取り、もう片方の山に2i個加える # 1手前に戻しつつ山の状態を列挙して、与えられた状態を探索する # ただし、石の個数の合計が与えられた石の個数の合計を超えたら探索を打ち切る # 山の状態を再帰的に探索する def recur_search(x,y,Alice_win_flg): if x+y > X+Y or x < 0 or y < 0: return elif [x, y] in...
s866015331
p03740
u886747123
1570347688
Python
Python (3.4.3)
py
Runtime Error
86
3928
1175
X, Y = map(int, input().split()) # 最終状態は(0,1), (1,1)のいずれか # 最終状態の1手前は勝ち確状態、その1手前は負け確状態 # 1手前に戻すには片方の山からi個石を取り、もう片方の山に2i個加える # 1手前に戻しつつ山の状態を列挙して、与えられた状態を探索する # ただし、石の個数の合計が与えられた石の個数の合計を超えたら探索を打ち切る # 山の状態を再帰的に探索する def recur_search(x,y,Alice_win_flg): if x+y > X+Y or x < 0 or y < 0: return elif [x, y] in...
s750773798
p03740
u886747123
1570346974
Python
Python (3.4.3)
py
Runtime Error
188
3928
1092
X, Y = map(int, input().split()) # 最終状態は(0,1), (1,1)のいずれか # 最終状態の1手前は勝ち確状態、その1手前は負け確状態 # 1手前に戻すには片方の山からi個石を取り、もう片方の山に2i個加える # 1手前に戻しつつ山の状態を列挙して、与えられた状態を探索する # ただし、石の個数の合計が与えられた石の個数の合計を超えたら探索を打ち切る # 山の状態を探索し、与えられた状態と一致したらフラグを保存する def recur_search(x,y,Alice_win_flg): if [x,y] == [X,Y] or [x,y] == [Y,X]: Ali...
s118408638
p03740
u511965386
1565384398
Python
PyPy3 (2.4.0)
py
Runtime Error
312
47472
306
X, Y = map(int, input().split()) def rec(x, y) : flg = False for i in range(2, x + 1, 2) : flg = flg or not rec(x-i, y+i//2) for i in range(2, y + 1, 2) : flg = flg or not rec(x+i//2, y-i) return flg if rec(X, Y) : print('Alice') else : print('Brown')
s551366679
p03740
u595893956
1563835872
Python
Python (3.4.3)
py
Runtime Error
17
2940
63
a,b = map(int,input()) print("ABlriocwen"[not abs(a-b)>1 :: 2])
s825618179
p03740
u189575640
1551805951
Python
Python (3.4.3)
py
Runtime Error
77
4040
682
import sys AB = [int(n) for n in input().split()] # N = int(input()) # a = [int(input()) for _ in range(N)] # S = str(input()) # L = len(S) # T = str(input()) fin = [[0,0],[1,0],[0,1]] Alice = True memo = {} def Alicewin(state,Alice): if(state in fin and Alice): return False elif(state in fin and not Al...
s569444222
p03740
u490305870
1551562775
Python
Python (3.4.3)
py
Runtime Error
17
2940
232
¥X,Y = map(int,input().split()) def judege(Z): ans = int(Z/2) re = Z%2 # print(ans,re) if ans == 0: if re == 0: return "Brown" else: return "Alice" else: return judege(ans+re) print(judege(X+Y))
s328480688
p03740
u794173881
1551049218
Python
Python (3.4.3)
py
Runtime Error
17
2940
64
x,y =map(int,input()) print("Brown" if abs(x-y)<=1 else "Alice")
s184583134
p03740
u794173881
1550335392
Python
Python (3.4.3)
py
Runtime Error
21
3316
854
from collections import deque n,m = map(int,input().split()) info = [list(map(int,input().split())) for i in range(m)] tree = [[] for i in range(n)] for i in range(m): tree[info[i][0]-1].append([info[i][0]-1,info[i][1]-1,info[i][2],False]) flag= [False] visited =[-float("inf")]*n visited[0]=0 count = [0] def bfs(...
s586087127
p03740
u522398430
1529553000
Python
Python (3.4.3)
py
Runtime Error
151
12508
387
import numpy x,y = map(int, input().split()) z = np.array([x,y]) i = 1 if z[z.argmax()] == 0 or z[z.argmax()] == 1: i = 1 else: while True: amax, amin = z.argmax(), z.argmin() z[amin] += z[amax]//2 z[amax] = 1 if z[amax]%2 else 0 i+=1 if (z[z.argmax()] == 0 or z[z.argma...
s163622771
p03740
u522398430
1529552921
Python
Python (3.4.3)
py
Runtime Error
305
21136
386
import numpy x,y = map(int, input().split()) z = np.array([x,y]) i = 1 if z[z.argmax()] == 0 or z[z.argmax()] == 1: i = 1 else: while True: amax, amin = z.argmax(), z.argmin() z[amin] += z[amax]//2 z[amax] = 1 if z[amax]%2 else 0 i+=1 if (z[z.argmax()] == 0 or z[z.argma...
s244268585
p03740
u391475811
1525480455
Python
Python (3.4.3)
py
Runtime Error
18
3188
86
X,Y=map(int,input()) if max(X,Y)-min(X,Y) > 1: print("Alice") else: print("Brown")
s346886014
p03740
u888275483
1493732486
Python
Python (2.7.6)
py
Runtime Error
10
2568
141
#!/usr/bin/env python # -*- coding: utf-8 -*- A, B = map(int, raw_input().split()) if abs(A - B) < 2 print("Brown") else: print("Alice")
s140504696
p03740
u579170193
1493242261
Python
Python (3.4.3)
py
Runtime Error
17
2940
69
a,b=map(int,raw_input().split());print(abs(a-b)<2and'Brown'or'Alice')
s924013038
p03740
u009102496
1493082188
Python
Python (3.4.3)
py
Runtime Error
17
2940
88
a,b=map(int,input().split()) if abs(a-b)<2: print("Brown") elif: print("Alice")
s881053290
p03741
u780475861
1590250068
Python
Python (3.4.3)
py
Runtime Error
43
14084
403
import sys def func(lst, sign): cur, res = 0, 0 for i in alst: cur += i if sign and cur <= 0: res += abs(cur) + 1 cur = 1 elif not sign and cur >= 0: res += abs(cur) + 1 cur = -1 sign = not sign return res def main(): n, *alst = map(int, sys.stdin.read().split()) pr...
s227457514
p03741
u921773161
1565792757
Python
Python (3.4.3)
py
Runtime Error
107
14332
2955
n = int(input()) a = list(map(int, input().split())) tmp = 0 ans = 0 if a[0] != 0: for i in range(n): if i == 0 : tmp += a[i] elif i % 2 == 1: tmp += a[i] if a[0] > 0: if tmp < 0 : pass elif tmp >= 0 : ...
s717533540
p03741
u921773161
1565792673
Python
Python (3.4.3)
py
Runtime Error
107
14332
2929
n = int(input()) a = list(map(int, input().split())) tmp = 0 ans = 0 if a[0] != 0: for i in range(n): if i == 0 : tmp += a[i] elif i % 2 == 1: tmp += a[i] if a[0] > 0: if tmp < 0 : pass elif tmp >= 0 : ...
s754338597
p03741
u879870653
1549144859
Python
Python (3.4.3)
py
Runtime Error
44
14332
546
N = int(input()) A = list(map(int,input().split())) ans = 0 sum_A = A[0] for i in range(1,N) : if ((sum_A + A[i]) == 0) or (sum_A *(sum_A + A[i]) >= 0) : if sum_A > 0 : ans += 1 + sum_A + A[i] #print("ans += {}".format(1 + sum_A + A[i])) sum_A = -1 elif sum_A <...
s738232500
p03741
u663710122
1544736542
Python
Python (3.4.3)
py
Runtime Error
104
14332
331
_ = int(input()) A = list(map(int, input().split())) def solve(i, s, k, sign): if i >= len(A): return k if sign * (s + A[i]) > 0: return solve(i + 1, s + A[i], k, sign * -1) else: return solve(i + 1, sign, k + abs(s + A[i]) + 1, sign * -1) print(min(solve(0, 0, 0, 1), solve(0, 0...
s554414093
p03741
u663710122
1544736429
Python
Python (3.4.3)
py
Runtime Error
103
14332
326
N = int(input()) A = list(map(int, input().split())) def solve(i, s, k, sign): if i >= N: return k if sign * (s + A[i]) > 0: return solve(i + 1, s + A[i], k, sign * -1) else: return solve(i + 1, sign, k + abs(s + A[i]) + 1, sign * -1) print(min(solve(0, 0, 0, 1), solve(0, 0, 0, ...
s989573375
p03741
u663710122
1544736304
Python
Python (3.4.3)
py
Runtime Error
103
14332
331
N = int(input()) A = list(map(int, input().split())) def solve(i, s, k, sign): if i == N: return k if sign * (s + A[i]) > 0: return solve(i + 1, s + A[i], k, sign * -1) else: return solve(i + 1, sign, k + abs(s + A[i]) + 1, sign * -1) a = solve(0, 0, 0, 1) b = solve(0, 0, 0, -1)...
s639080159
p03741
u663710122
1544736270
Python
Python (3.4.3)
py
Runtime Error
107
14468
364
N = int(input()) A = list(map(int, input().split())) def solve(i, s, k, sign): if i == N: return k if sign * (s + A[i]) > 0: return solve(i + 1, s + A[i], k, sign * -1) else: return solve(i + 1, sign, k + abs(s + A[i]) + 1, sign * -1) a = solve(0, 0, 0, 1) b = solve(0, 0, 0, -1)...