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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s364636716 | p04019 | u848647227 | 1546108531 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 136 | ar = list(input())
br = set(ar)
if br.count("N") == br.count("S") and br.count("W") == br.count("E"):
print("Yes")
else:
print("No") |
s585434670 | p04019 | u371467115 | 1545855220 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 98 | s=list(input())
s_s=set(s)
l={"W","N","E","S"}
if s_s==l:
print("Yes")
else:
print(("No") |
s184927449 | p04019 | u371467115 | 1545854732 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 116 | s=list(input())
if l.count("N")==l.count("S") and l.count("E")==l.count("W"):
print("Yes")
else:
print("No") |
s898238719 | p04019 | u940102677 | 1538442284 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 98 | a = set(list(input()))
print("Yes" if ~("N" in a ^ "S" in a) and ~("W" in a ^ "E" in a) else "No") |
s326974317 | p04019 | u723721005 | 1537235929 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 80 | s = input()
print(['Yes','No'][('N'in s)^('S'in s)|('E'in s)^('W'in s)]) |
s137929188 | p04019 | u476418095 | 1533930572 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 146 | s = set(input())
l = len(s)
if l in [1, 3]:
print 'No'
elif l == 4:
print 'Yes'
else:
print ['No', 'Yes'][s in [set('NS'), set('WE')]] |
s617426635 | p04019 | u627417051 | 1531460126 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 400 | S = list(input())
if S.count("N") == 0 and S.count("S") == 0:
if S.count("E") >= 1 and S.count("W") >= 1:
print("Yes")
else:
print("NO")
elif S.count("E") == 0 and S.count("W") == 0:
if S.count("N") >= 1 and S.count("S") >= 1:
print("Yes")
else:
print("NO")
else:
if S.count("N") >= 1 and S.count("S") >= 1 and S.count("W") >= 1 and S.count("E") >= 1:
print("Yes")
else:
print("No") |
s813964253 | p04019 | u816631826 | 1530642081 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 336 | def main():
for line in sys.stdin:
s = line
if (('N' in s) and ('S' in s)) and not (('W' in s) or ('E' in s)):
print("Yes")
elif (('W' in s) and ('E' in s)) and not (('N' in s) or ('S' in s)):
print("Yes")
elif (('W' in s) and ('E' in s)) and (('N' in s) and ('S' in s)):
print("Yes")
else:
print("No")
main() |
s540854186 | p04019 | u089230684 | 1530641907 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 328 | def main():
for line in sys.stdin:
s = line
if (('N' in s) and ('S' in s)) and not (('W' in s) or ('E' in s)):
print("Yes")
elif (('W' in s) and ('E' in s)) and not (('N' in s) or ('S' in s)):
print("Yes")
elif (('W' in s) and ('E' in s)) and (('N' in s) and ('S' in s)):
print("Yes")
else:
print("No") |
s088507066 | p04019 | u353919145 | 1530641907 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 353 | def back_home():
r=input()
t=r.count('S') +1
y=r.count('N') +1
u=r.count('W') +1
i=r.count('E')+1
if (t>1 and y>1 and u==1 and i==1):
print("YES")
elif((t==1 and y==1 and u>1 and i>1):
print("YES")
elif ((t>1 and y>1 and u>1 and i>1):
print("YES")
else:
print("NO")
back_home() |
s646728447 | p04019 | u816631826 | 1530621152 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 354 | def back_home():
r=input()
t=r.count('S') +1
y=r.count('N') +1
u=r.count('W') +1
i=r.count('E')+1
if (t>1 and y>1 and u==1 and i==1):
print("YES")
elif((t==1 and y==1 and u>1 and i>1):
print("YES")
elif ((t>1 and y>1 and u>1 and i>1):
return("YES")
else:
print("NO")
back_home() |
s577985034 | p04019 | u816631826 | 1530621052 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 357 | def back_home():
r=input()
t=r.count('S') +1
y=r.count('N') +1
u=r.count('W') +1
i=r.count('E')+1
if (t>1 and y>1 and u==1 and i==1):
return("YES")
elif((t==1 and y==1 and u>1 and i>1):
return("YES")
elif ((t>1 and y>1 and u>1 and i>1):
return("YES")
else:
return("NO")
back_home() |
s828645735 | p04019 | u863370423 | 1530620647 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 477 | def back_home():
r=input()
print(r)
l = dict()
for i in r:
if i in l:
l[i]=int(l[i])+1
else:
l[i]=1
if (len(l)==1):
return('NO')
elif(len(l)==2):
if (l['S']>0 and l['N']>0):
return ("yes")
elif(l['E']>0 and l['W']>0):
return("yes")
else:
return("NO")
elif(len(l)==3):
return("NO")
else:
return("YES")
back_home() |
s926445282 | p04019 | u353919145 | 1530620049 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 473 | def back_home(r):
l = dict()
for i in r:
if i in l:
l[i]=int(l[i])+1
else:
l[i]=1
if (len(l)==1):
return('NO')
elif(len(l)==2):
if (len(l['S'])>0 and len(l['N']>0)):
return ("yes")
elif(len(l['E'])>0 and len(l['W']>0)):
return("yes")
else:
return("NO")
elif(len(l)==3):
return("NO")
else:
return("YES")
back_home(S): |
s431183623 | p04019 | u676264453 | 1499726021 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 362 | def ch(l):
return l[0] != l[-1]
S = str(input())
v = []
h = []
for i in range(len(S)):
p = S[i]
if (p in 'NS'):
v.append(p)
else:
h.append(p)
if (len(v) == 0 and len(h) == 0):
print('Yes')
elif (len(v) == 0 and ch(h)):
print('Yes')
elif (len(h) == 0 and ch(v)):
print('Yes')
elif (ch(h) and ch(v)):
print('Yes')
else:
print('No')
|
s390001963 | p04019 | u272028993 | 1493265927 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2568 | 380 | s=raw_input()
n=False
e=False
w=False
ss=False
for i in xrange(len(s)):
if s[i]=="N":n=True
elif s[i]=="E":e=True
elif s[i]=="W":w=True
else:ss=True
if (n and ss) or (e and w):
print("Yes")
else:
if not n and not ss and not e and not w:
print("Yes")
else:
print("No")
|
s277065098 | p04019 | u272028993 | 1493265890 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2568 | 409 | s=raw_input()
n=False
e=False
w=False
ss=False
for i in xrange(n):
if s[i]=="N":n=True
elif s[i]=="E":e=True
elif s[i]=="W":w=True
else:ss=True
if (n and ss) or (e and w):
print("Yes")
else:
if not n and not ss and not e and not w:
print("Yes")
else:
print("No")
else:
if not n and not ss and not e and not w:
print("YES")
else:
print("NO") |
s435897074 | p04019 | u187430339 | 1474675181 | Python | Python (2.7.6) | py | Runtime Error | 16 | 2692 | 460 | import sys
#sys.stdin = open('b_2.txt', 'r')
N = int(raw_input())
rest = [0 for _ in range(N)]
ins = [0 for _ in range(N)]
pairs = 0
for x in range(N):
n = long(raw_input())
ins[x] = n
pairs += n / 2
rest[x] = n % 2
for x in range(0, N - 1, 1):
if ((rest[x] == 1) and (rest[x + 1] == 1)):
pairs += 1
elif ((rest[x] == 1) and (rest[x + 1] == 0) and (ins[x + 1] > 0)):
rest[x + 1] = 1
ins[x + 1] -= 2
rest[x] = 0
else:
pass
print str(pairs)
|
s390565848 | p04019 | u886545507 | 1474209898 | Python | PyPy2 (5.6.0) | py | Runtime Error | 58 | 8816 | 219 | #AGC003B
n=int(raw_input())
s=[]
for i in xrange(1,n+1):
x=int(raw_input())
for j in xrange(x):
s.append(i)
cnt=0
i=0
while i<len(s)-1:
if s[i+1]-s[i]==0 or s[i+1]-s[i]==1:
cnt+=1
i+=2
else:
i+=1
print cnt
|
s955479594 | p04019 | u886545507 | 1474209676 | Python | Python (2.7.6) | py | Runtime Error | 26 | 2568 | 219 | #AGC003B
n=int(raw_input())
s=[]
for i in xrange(1,n+1):
x=int(raw_input())
for j in xrange(x):
s.append(i)
cnt=0
i=0
while i<len(s)-1:
if s[i+1]-s[i]==0 or s[i+1]-s[i]==1:
cnt+=1
i+=2
else:
i+=1
print cnt
|
s082990921 | p04019 | u612721349 | 1473307856 | Python | Python (3.4.3) | py | Runtime Error | 57 | 3700 | 186 | from collections import Counter
c = Counter(input())
print("Yes" if ((c["N"] > 0 and c["S"] > 0) or c["N"] == s["S"]) \
and ((c["E"] > 0 and c["W"] > 0) or c["E"] == s["W"]) else "No")
|
s317157280 | p04019 | u091855288 | 1472952904 | Python | Python (2.7.6) | py | Runtime Error | 29 | 2692 | 216 | N = int(raw_input())
A = [0] * N
for idx in xrange(N):
A[idx] = int(raw_input())
total = 0
pre = 0
for item in A:
total += (item+pre) / 2
if item == 0:
pre = 0
else:
pre = (item+pre) % 2
print total |
s285132189 | p04019 | u091855288 | 1472952867 | Python | Python (2.7.6) | py | Runtime Error | 145 | 10512 | 236 | import numpy as np
N = int(raw_input())
A = [0] * N
for idx in xrange(N):
A[idx] = int(raw_input())
total = 0
pre = 0
for item in A:
total += (item+pre) / 2
if item == 0:
pre = 0
else:
pre = (item+pre) % 2
print total |
s121800068 | p04019 | u866746776 | 1472806178 | Python | Python (3.4.3) | py | Runtime Error | 38 | 3064 | 232 | n, w, s, e = 0
for c in input():
if c == "N":
n += 1
if c == "W":
w += 1
if c == "S":
s += 1
if c == "E":
e += 1
b = ((n >= 1 and s >= 1) or (n==s==0)) and ((w >= 1 and e >= 1) or (w==e==0))
print("Yes" if b else "No")
|
s978304354 | p04019 | u914627967 | 1472507583 | Python | Python (3.4.3) | py | Runtime Error | 42 | 3192 | 428 | #coding: cp932
N = int(input())
inp =[]
for s in range(N):
inp.append(int(input()))
check = inp[:]
check.sort()
flag=1
s,ans,lis2 = 0,0,[]
while flag==1:
#lis.append(check[s])
lis2.append(inp[s])
s+=2
if s>N-1:
flag=0
num =len(lis)
#print(lis)
#print(lis2)
for s in range(num):
if s!=0:
if check[s+2] not in lis2:
ans+=1
lis[s] =-1
continue
else:
if check[s] not in lis2:
ans+=1
lis[s]=-1
print(ans)
|
s607812794 | p04019 | u914627967 | 1472071455 | Python | Python (3.4.3) | py | Runtime Error | 42 | 3192 | 229 | #coding: cp932
N = int(input())
i=[]
for s in range(N):
i.append(input())
ans=0
for s in range(N-1):
if i[1+s]==0:
continue
cul= int((i[1+s]+i[2+s])/2)
ans += cul
if i[1+s]>i[2+s]:
amari = (i[1+s]+i[2+s])%2
print(ans)
|
s083929346 | p04019 | u914627967 | 1472071247 | Python | Python (3.4.3) | py | Runtime Error | 53 | 3820 | 255 | #coding: cp932
i=int(input())
#i = [int(input())for s in range(M)]
i = list(i)
#print(i)
N = int(i[0])
ans=0
for s in range(N-1):
if i[1+s]==0:
continue
cul= int((i[1+s]+i[2+s])/2)
ans += cul
if i[1+s]>i[2+s]:
amari = (i[1+s]+i[2+s])%2
print(ans)
|
s907219881 | p04019 | u813356465 | 1471834185 | Python | PyPy2 (5.6.0) | py | Runtime Error | 121 | 12272 | 1262 | import math
import collections
p_max = int(10**(10./3))
marked = [True]*2+[False]*(p_max-2)
ps = []
for n in range(2,p_max):
if marked[n]:
continue
ps.append(n)
for n2 in range(n, p_max):
if n2 % n == 0:
marked[n2] = True
def getexp(n, p):
ans = 0
while n > 1 and n % p == 0:
ans += 1
n = n // p
return ans
def getcanon(n):
canon = []
for p in ps:
if n == 1:
return tuple(canon)
e = getexp(n, p)
n = n//(p**e)
if e % 3 != 0:
canon.append((p, e % 3))
sqr = int(math.sqrt(n+0.5))
if sqr**2 == n:
canon.append((sqr, 2))
else:
canon.append((n,1))
return tuple(canon)
def getcomp(canon):
return tuple([(p,3-e) for (p,e) in canon])
N = int(raw_input())
s = [int(raw_input()) for i in range(N)]
ctr = collections.Counter()
for si in s:
ctr[getcanon(si)] += 1
ans = 0
cans = list(ctr.keys())
for can in cans:
ct = ctr[can]
if ct == 0:
continue
if can == ():
ans += 1
ctr[can] = 0
continue
comp = getcomp(can)
c_ct = ctr[comp]
if c_ct == 0:
ans += ct
else:
ans += max(ct, c_ct)
ctr[comp] = 0
print ans |
s279825152 | p04019 | u945094648 | 1471829612 | Python | Python (2.7.6) | py | Runtime Error | 27 | 2568 | 156 | n=raw_input()
a=n[-1:]
b=n[-2:]
if a==N and b==S or a==S and b==N:
print "Yes"
elif a==E and b==W or a==W and b==E:
print "Yes"
else:
print "No" |
s345790567 | p04019 | u159043787 | 1471829595 | Python | Python (2.7.6) | py | Runtime Error | 27 | 2568 | 295 | #
N = input()
#S = []
count = 0
flag = 0
for i in range(1,N+1):
IN = input()
#S.append(IN)
if flag:
if (flag == i - 1):
if IN > 0:
IN -= 1
count += 1
flag = 0
count += IN/2
if IN%2 == 1:
flag = i
print count
|
s913123452 | p04019 | u492932526 | 1471828630 | Python | Python (2.7.6) | py | Runtime Error | 25 | 2568 | 263 | # coding: UTF-8
s = raw_input()
if 'N' in s and 'W' in s and 'S' in s and 'E' in s:
print "Yes"
elif 'N' in s and not 'W' in s and 'S' in s and not 'E' in s:
print "Yes"
elif not 'N' in s and 'W' in s and not 'S' in s and 'E' in s:
else :
print "No"
|
s008695526 | p04019 | u756132450 | 1471828401 | Python | Python (3.4.3) | py | Runtime Error | 39 | 3064 | 134 | s = input()
a = s.count("S") - s.count("N")
b = s.count("E") - s.count("W")
if (a == 0 && a == b):
print ("Yes")
else:
print ("No")
|
s326039414 | p04019 | u123756661 | 1471827907 | Python | Python (2.7.6) | py | Runtime Error | 26 | 2568 | 142 | s=list(raw_input())
s=set(s)
print 'Yes' if len(s)==4 or (len(s)==2 and 'S' in s and 'N' in s) or (len(2) and 'W' in s and 'E' in s) else 'No' |
s475930262 | p04020 | u644907318 | 1599827349 | Python | PyPy3 (7.3.0) | py | Runtime Error | 113 | 74416 | 204 | N = int(input())
A = list(map(int,input().split()))
cnt = 0
for i in range(N):
cnt += A[i]//2
A[i] = A[i]%2
for i in range(1,N-1):
if A[i-1]+A[i]==2:
cnt += 1
A[i]=0
print(cnt) |
s405237771 | p04020 | u192154323 | 1598114275 | Python | PyPy3 (7.3.0) | py | Runtime Error | 187 | 81688 | 550 | N = int(input())
ls = [0] * N
for i in range(N):
a = int(input())
ls[i] = a
def return_ans(ls):
ans = 0
n = len(ls)
if n > 1:
for i in range(n-1):
if ls[i] % 2 == 1 and ls[i+1] > 0:
ls[i] += 1
ls[i+1] -= 1
ans += ls[i] // 2
ans += ls[-1]//2
return ans
now_ls = []
ans = 0
for i in range(N):
if ls[i] != 0:
now_ls.append(ls[i])
else:
ans += return_ans(now_ls)
now_ls = []
if now_ls:
ans += return_ans(now_ls)
print(ans)
|
s054192179 | p04020 | u368796742 | 1597884740 | Python | Python (3.8.2) | py | Runtime Error | 145 | 13712 | 303 | n = int(input())
ans = 0
lis = [int(input()) for i in range(n)]+[0]
count = 0
m = -1
for i in range(n):
if lis[i]%2 == 0:
count += l[i]//2
else:
if lis[i+1] > 1:
count += lis[i]//2+1
lis[i+1] -= 1
else:
count += lis[i]//2
print(count) |
s450804680 | p04020 | u730769327 | 1596079053 | Python | PyPy3 (7.3.0) | py | Runtime Error | 521 | 99084 | 384 | from copy import copy
n=int(input())
a=[int(input()) for _ in range(n)]
b=copy(a)
ans1=0
for i in range(n-1):
ans1+=min(a[i],a[i+1])
k=max(a[i]-a[i+1],0)
a[i+1]=max(a[i+1]-a[i],0)
a[i]=k
for i in a:
ans1+=i//2
ans2=0
for i in range(n-1,0,-1):
ans2+=min(b[i],b[i-1])
k=max(b[i]-b[i-1],0)
b[i+1]=max(b[i-1]-b[i],0)
b[i]=k
for i in b:
ans2+=i//2
print(max(ans1,ans2)) |
s067892648 | p04020 | u879309973 | 1595910283 | Python | Python (3.8.2) | py | Runtime Error | 184 | 12924 | 320 | def solve(n, a):
res = 0
for i in range(n-1):
b = min(a[i], a[i+1])
res += b
a[i] -= b
a[i+1] -= b
if a[i] > 0:
res += a[i] // 2
if a[-1] > 0:
res += a[i] // 2
return res
n = int(input())
a = [int(input()) for i in range(n)]
print(solve(n, a)) |
s695185460 | p04020 | u439434613 | 1595712296 | Python | Python (3.8.2) | py | Runtime Error | 2292 | 3523280 | 282 | N = int(input())
ls = []
for i in range(N):
n = int(input())
ls.extend([i+1]*n)
count = 0
prev = ls[0]
pair = False
for i in ls[1:]:
if pair == True:
pair = False
prev = i
continue
if i - prev <= 1:
count += 1
pair = True
prev = i
print(count) |
s529521474 | p04020 | u747703115 | 1595702751 | Python | Python (3.8.2) | py | Runtime Error | 67 | 9140 | 210 | import sys
n = int(sys.stdin.readline())
ans = 0
t = 0
for i in range(n):
a = int(sys.stdin.readline())
if a==0:
ans += t//2
t = 0
else:
t += a
if t>0: ans += t//2
pritn(ans) |
s929661786 | p04020 | u801049006 | 1592176692 | Python | Python (3.4.3) | py | Runtime Error | 261 | 11748 | 165 | n = int(input())
a = [int(input()) for _ in range(n)]
dp = [0] * n
for i in range(n):
dp[i] = max(dp[i-1] + a[i]//2,dp[i-2] + min(a[i-1], a[i]))
print(dp[-1])
|
s996154274 | p04020 | u462329577 | 1592082693 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 368 | #include <bits/stdc++.h>
using namespace std;
int main()
{
int N;
cin >> N;
vector<long long> a(N);
for (int i = 0; i < N; ++i)
cin >> a[i];
long long res = 0, cur_sum = 0;
for (int i = 0; i < N;)
{
int j = i;
while (j < N && a[j])
cur_sum += a[j++];
res += cur_sum / 2;
cur_sum = 0;
i = j + 1;
}
cout << res << endl;
} |
s675913915 | p04020 | u408375121 | 1589915008 | Python | Python (3.4.3) | py | Runtime Error | 278 | 7076 | 260 | n = int(input())
A = []
for _ in range(n):
a = int(input())
A.append(a)
if n == 1:
cnt = A[0]//2
else:
cnt = 0
for i in range(n-1):
m = min(A[i], A[i+1])
cnt += m
A[i] -= m
A[i+1] -= m
cnt += A[i]//2
cnt += A[n]//2
print(cnt)
|
s422499413 | p04020 | u105124953 | 1589408211 | Python | Python (3.4.3) | py | Runtime Error | 2139 | 1297012 | 254 | n = int(input())
ans = 0
li = []
tmp = []
for i in range(n):
num = i+1
t = int(input())
if t == 0:
li.append(tmp)
tmp = []
else:
tmp += [num]*t
li.append(tmp)
for l in li:
ans += len(l)//2
#print(li)
print(ans) |
s950807038 | p04020 | u105124953 | 1589408085 | Python | PyPy3 (2.4.0) | py | Runtime Error | 1964 | 1326108 | 254 | n = int(input())
ans = 0
li = []
tmp = []
for i in range(n):
num = i+1
t = int(input())
if t == 0:
li.append(tmp)
tmp = []
else:
tmp += [num]*t
li.append(tmp)
for l in li:
ans += len(l)//2
#print(li)
print(ans) |
s469046920 | p04020 | u373047809 | 1588866079 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 97 | k,s=open(0);n,r=map(int,k.split());a=0
while n>0:
n-=1
if s[n]<"o":n-=~-r;a=-~max(a,n)
print(a) |
s196152582 | p04020 | u476604182 | 1587929337 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 172 | N, *A = map(int, open('0').read().split())
ans = sum(c//2 for c in A)
A = [c%2 for c in A]
for i in range(N-2):
if A[i]==A[i+1]==1:
A[i+1] = 0
ans += 1
print(ans) |
s531043204 | p04020 | u405256066 | 1586137193 | Python | Python (3.4.3) | py | Runtime Error | 462 | 7856 | 527 | from sys import stdin
N = int(stdin.readline().rstrip())
A = []
for i in range(N):
A.append(int(input()))
B = A[:]
ans1 = 0
for j in range(N):
ans1 += (A[j]//2)
A[j] = (A[j]%2)
for k in range(1,N):
ans1 += min(A[k-1],A[k])
A[k] = A[k] - min(A[k-1],A[k])
ans2 = 0
tmp = min(B[0],B[1])
for l in range(1,N):
ans2 += min(B[l-1],B[l])
B[l] = B[l] - min(B[l-1],B[l])
B[l-1] = B[l-1] - min(B[l-1],B[l])
B[0] -= tmp
for m in range(N):
ans2 += (B[m]//2)
print(max(ans1,ans2)) |
s799792795 | p04020 | u524870111 | 1582514725 | Python | Python (3.4.3) | py | Runtime Error | 2108 | 141620 | 453 | import sys
stdin = sys.stdin
import itertools
mod = 10**9 + 7
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
N = ni()
A = list()
for _ in range(N):
A.append(ni())
cnt = 0
if N==1:
print(A[0]//2)
quit()
for i in range(N-1):
print(A)
ccnt = (A[i] + A[i+1]) //2
A[i+1] -= max(0, ccnt*2 - A[i])
A[i] = max(0, A[i]-ccnt*2)
cnt += ccnt
print(A)
print(cnt) |
s174679968 | p04020 | u620755587 | 1580517020 | Python | Python (3.4.3) | py | Runtime Error | 2130 | 1296756 | 244 | n = int(input())
c = []
for i in range(n):
c += [i+1]*int(input())
cnt = 0
paired = False
for i in range(len(c)-1):
if paired:
paired = False
continue
if c[i+1] - c[i] <= 1 and not paired:
cnt += 1
paired = True
print(cnt) |
s799705454 | p04020 | u905582793 | 1577034850 | Python | Python (3.4.3) | py | Runtime Error | 177 | 7072 | 171 | n=int(input())
a = [int(input()) for i in range(n)]
a.append(0)
ans = 0
for i in range(n+1):
if a[i]!=0:
tmp += a[i]
else:
ans += tmp//2
tmp = 0
print(ans) |
s994795885 | p04020 | u530606147 | 1576799788 | Python | Python (3.4.3) | py | Runtime Error | 2264 | 4136 | 258 | n = int(input())
a = [int(input()) for _ in range(n)]
s=''
for i,x in enumerate(a):
if x != 0:
s += str(i+1)*x
else:
s += '*'
s += '*'
ans=0
cnt=0
for c in s:
if c != '*':
cnt += 1
else:
ans += cnt // 2
cnt=0
print(ans)
|
s060831933 | p04020 | u948524308 | 1576538581 | Python | Python (3.4.3) | py | Runtime Error | 292 | 11764 | 234 | N=int(input())
A=[0]*N
DP=[0]*N
for i in range(N):
A[i]=int(input())
DP[0]=A[0]//2
DP[1]=max(A[0]//2+A[1]//2,min(A[0],A[1]))
for i in range(2,N):
DP[i]=max(DP[i-2]+A[i-1]//2+A[i]//2,DP[i-2]+min(A[i-1],A[i]))
print(DP[N-1]) |
s039516343 | p04020 | u405660020 | 1575325676 | Python | Python (3.4.3) | py | Runtime Error | 202 | 7072 | 290 | n=int(input())
a=[int(input()) for _ in range(n)]
if a.count(0)==0:
print(sum(a//2))
else:
tmp_sum=0
ans=0
for i in range(n):
if a[i]==0:
ans+=tmp_sum//2
tmp_sum=0
else:
tmp_sum+=a[i]
ans+=tmp_sum//2
print(ans)
|
s766405641 | p04020 | u116002573 | 1568182189 | Python | Python (3.4.3) | py | Runtime Error | 315 | 7072 | 400 | def main():
N = int(input())
A = []
for _ in range(N):
A.append(int(input()))
# print(A)
pairs = 0
for i in range(N-1):
pairs += A[i] // 2
A[i] = A[i] % 2
pairs += min(A[i], A[i+1])
A[i], A[i+1] = A[i]-min(A[i], A[i+1]), A[i+1]-min(A[i], A[i+1])
pairs += A[i+1] // 2
return pairs
if __name__ == '__main__':
print(main()) |
s207911795 | p04020 | u116002573 | 1568182079 | Python | Python (3.4.3) | py | Runtime Error | 293 | 7072 | 376 | def main():
N = int(input())
A = []
for _ in range(N):
A.append(int(input()))
# print(A)
pairs = 0
for i in range(N-1):
pairs += min(A[i], A[i+1])
A[i], A[i+1] = A[i]-min(A[i], A[i+1]), A[i+1]-min(A[i], A[i+1])
pairs += A[i] // 2
pairs += A[i+1] // 2
return pairs
if __name__ == '__main__':
print(main()) |
s844092160 | p04020 | u312025627 | 1568075558 | Python | PyPy3 (2.4.0) | py | Runtime Error | 584 | 55896 | 2311 | def main():
n = int(input())
a = [int(input()) for _ in range(n)]
ans = 0
changing = [a[0]]
direct_flag = False #False > True <
for i in range(1,n):
if len(changing) == 1:
changing.append(a[i])
if changing[0] < changing[1]:
direct_flag = True
else:
if direct_flag and changing[-1] < a[i]:
changing.append(a[i])
elif not direct_flag and changing[-1] > a[i]:
changing.append(a[i])
else:
m = len(changing)
iterange = (range(m) if direct_flag else range(m)[::-1])
for j in iterange:
if j != 0:
makable = min(changing[j-1],changing[j])
ans += makable
changing[j-1] -= makable
changing[j] -= makable
if j != m-1:
makable = min(changing[j],changing[j+1])
ans += makable
changing[j] -= makable
changing[j+1] -= makable
if changing[j] >= 2:
makable = changing[j] // 2
ans += makable
changing[j] -= makable * 2
changing = [a[i]]
direct_flag = False
if i == n-1:
if len(changing) == 1:
ans += changing[0] // 2
else:
iterange = (range(m) if direct_flag else range(m)[::-1])
for j in iterange:
if j != 0:
makable = min(changing[j-1],changing[j])
ans += makable
changing[j-1] -= makable
changing[j] -= makable
if j != m-1:
makable = min(changing[j],changing[j+1])
ans += makable
changing[j] -= makable
changing[j+1] -= makable
if changing[j] >= 2:
makable = changing[j] // 2
ans += makable
changing[j] -= makable * 2
print(ans)
if __name__ == "__main__":
main() |
s402488243 | p04020 | u077291787 | 1566810165 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 518 | # keyence2019C - Exam and Wizard
def main():
N = int(input())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))
dif = sorted(i - j for i, j in zip(A, B))
ans, shortage = 0, 0
for i in dif:
if i < 0:
ans += 1
shortage += i
else:
break
for i in dif[::-1]:
if shortage >= 0:
print(ans)
return
ans += 1
shortage += i
print(-1)
if __name__ == "__main__":
main() |
s441032697 | p04020 | u623687794 | 1563918723 | Python | PyPy3 (2.4.0) | py | Runtime Error | 170 | 38724 | 165 | n=int(input())
l=[int(input()) for i in range(n)]
ans=0
for i in range(n):
ans+=(l[i]-l[i]%2)//2
l[i]%=2
if l[i]==1
ans+=1
l[i]=0;l[i+1]-=1
print(ans)
|
s771033906 | p04020 | u623819879 | 1558472817 | Python | PyPy3 (2.4.0) | py | Runtime Error | 169 | 38256 | 130 | n=int(input())
tmp, ans=0,0
for i in range(n):
a=int(input())
if a=0:
ans+=tmp//2
tmp=0
else:
tmp+=a
print(ans)
|
s772105435 | p04020 | u285443936 | 1556018702 | Python | Python (3.4.3) | py | Runtime Error | 2536 | 1299096 | 262 | N = int(input())
A = [int(input()) for i in range(N)]
array = []
ans = 0
for i in range(N):
array += A[i] * [i+1]
array.sort()
for j in range(len(array)-1):
if abs(array[j] - array[j+1]) <= 1:
ans += 1
array[j] = -1
array[j+1] = -1
print(ans)
|
s456450813 | p04020 | u123756661 | 1555124789 | Python | PyPy3 (2.4.0) | py | Runtime Error | 513 | 43496 | 182 | n=int(input())
l=[0]
if n<200: print(l[100])
ans=chk=0
for i in range(n):
a=int(input())
ans+=(a+chk)//2
if a>0:
chk=(a+chk)%2
else:
chk=0
print(ans) |
s042336486 | p04020 | u572144347 | 1551835725 | Python | Python (3.4.3) | py | Runtime Error | 201 | 7072 | 189 | N=int(input())
A=[int(input()) for _ in range(N)]
ans=0
for i in range(N):
if A[i]==0:
idx.append(i+1)
n=0
idx.append(N)
for iidx in idx:
ans+=sum(A[n:iidx])//2
n=iidx
print(ans) |
s418670366 | p04020 | u572144347 | 1551835657 | Python | Python (3.4.3) | py | Runtime Error | 206 | 7072 | 193 | N=int(input())
A=[int(input()) for _ in range(N)]
ans=0
for i in range(N):
if A[i]==0:
idx.append(i+1)
n=0
idx.append(N)
for iidx in idx:
ans+=sum(A[n:iidx])//2
n=iidx
print(ans) |
s173334577 | p04020 | u572144347 | 1551835599 | Python | Python (3.4.3) | py | Runtime Error | 181 | 7072 | 179 | N=int(input())
A=[int(input()) for _ in range(N)]
ans=0
for i in range(N):
if A[i]==0:
idx.append(i+1)
n=0
for iidx in idx:
ans+=sum(A[n:iidx])//2
n=iidx
print(ans) |
s424467451 | p04020 | u572144347 | 1551833830 | Python | PyPy3 (2.4.0) | py | Runtime Error | 524 | 50904 | 527 | N=int(input())
A=[int(input()) for _ in range(N)]
ans=0
#0,1,2のみにする
for i in range(N):
a=A[i]
if a>=2 and a%2==0:
A[i]=2
ans+=(a-2)//2
elif a%2==1:
A[i]=1
ans+=(a-1)//2
elif a==0:
pass
for i in range(1,N-1):
b,a,c=A[i-1:i+1]
if a==2:
if b%2==1 and c %2==1:
A[i-1]-=1
A[i+1]-=1
A[i]-=2
ans+=2
for i in range(1,N):
a,b=A[i-1:i+1]
if a%2==1 and b%2==1:
ans+=1
A[i-1]-=1
A[i]-=1
ans+=len(list(filter(lambda x:x==2,A)))
print(ans)
|
s757241157 | p04020 | u572144347 | 1551792265 | Python | PyPy3 (2.4.0) | py | Runtime Error | 506 | 50904 | 233 | N=int(input())
A=[int(input()) for _ in range(N)]
ans=0
for i in range(1,N+1):
if A[i-1]>=A[i]:
ans+=A[i]
ans+=(A[i-1]-A[i])//2
A[i]=0
else:
ans+=A[i-1]
ans+=(A[i]-A[i-1])//2
A[i]-=A[i-1]
print(ans) |
s805176285 | p04020 | u794173881 | 1551317163 | Python | PyPy3 (2.4.0) | py | Runtime Error | 175 | 38640 | 529 | n,x = map(int,input().split())
a = list(map(int,input().split()))
#p[i色のスライム][j回まで色を変えられる]=色変えのコストを含まない最小コスト
p = [[0]*n for i in range(n)]
#print(p)
for i in range(n):
p[i][0]=a[i]
for j in range(1,n):
if i-j>=0:
p[i][j]=min(a[i-j],p[i][j-1])
elif i-j == -1:
p[i][j]=min(a[n-1],p[i][j-1])
else:
p[i][j]=min(a[n-(j-i)],p[i][j-1])
p = list(zip(*p))
ans = sum(p[0])
for i in range(1,n):
ans = min(ans,sum(p[i])+x*i)
print(ans) |
s724956747 | p04020 | u729133443 | 1548993836 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3828 | 82 | s=t=0
for _ in[0]*int(input()):a=int(input());s+=(a+t)//2;t=(a+t)%2&(i>0)
print(s) |
s375470301 | p04020 | u785578220 | 1546704551 | Python | Python (3.4.3) | py | Runtime Error | 239 | 8044 | 305 | a = int(input())
s = 0
p =[int(input()) for _ in range(a)]
p.append(0)
def cal(n,k,s):
#print(n,k,s,p[n])
if n== a:return s
s +=p[n]//2
c = p[n]%2
if p[n+1] >=1 and k == 1:
s +=1
p[n+1] -=1
return cal(n+1,c,s)
else:return cal(n+1,c,s)
print(cal(0,0,0)) |
s799395812 | p04020 | u422104747 | 1539603426 | Python | PyPy3 (2.4.0) | py | Runtime Error | 478 | 49368 | 230 | n=int(input())
l=[]
res=0
for i in range(n):
l.append(int(input()))
if i>0 and l[i]>0 and l[i-1]>0:
m=min(l[i],l[i+1])
res+=m
l[i]-=m
l[i+1]-=m
for i in range(n):
res+=l[i]//2
print(res) |
s648177324 | p04020 | u422104747 | 1539594649 | Python | PyPy3 (2.4.0) | py | Runtime Error | 164 | 38256 | 183 | n=int(input())
l=[]
for i in range(n):
j=int(input())
l.append(j%2)
res+=j//2
for i in range(n-1):
if l[i]==1 and l[i+1]==1:
res+=1
l[i+1]=0
print(res) |
s485591421 | p04020 | u690536347 | 1536252087 | Python | Python (3.4.3) | py | Runtime Error | 1847 | 1635956 | 170 | n=int(input())
l=[]
for i in range(1,n+1):
a=int(input())
l.extend([i]*a)
c=0
s=0
while s<len(l)-1:
if l[s+1]-l[s]<=1:
c+=1
s+=2
else:
s+=1
print(c) |
s538350055 | p04020 | u187430339 | 1474674320 | Python | Python (2.7.6) | py | Runtime Error | 16 | 2568 | 297 | import sys
sys.stdin = open('b_1.txt', 'r')
N = int(raw_input())
rest = [0 for _ in range(N)]
pairs = 0
for x in range(N):
n = long(raw_input())
pairs += n / 2
rest[x] = n % 2
for x in range(1, N, 1):
if ((rest[x - 1] == 1) and (rest[x] == 1)):
pairs += 1
rest[x] = 0
print str(pairs)
|
s180458614 | p04020 | u742897895 | 1472085477 | Python | PyPy3 (2.4.0) | py | Runtime Error | 984 | 58200 | 430 | n = int(input())
a = []
for i in range(n):
ai = int(input())
a.append(ai)
cnt = 0
i = 0
while True:
if a[i] >= 2:
pairs = a[i] // 2
cnt += pairs
a[i] -= (pairs * 2)
elif a[i] == 1:
if i + 1 >= n:
break
if a[i + 1] > 0:
cnt += 1
a[i] -= 1
a[i + 1] -= 1
else:
i += 1
else:
i += 1
print(cnt) |
s780485170 | p04020 | u914627967 | 1472071105 | Python | Python (3.4.3) | py | Runtime Error | 46 | 3192 | 255 | #coding: cp932
#M=int(input())
i = [int(input())for s in range(M)]
i = list(i)
#print(i)
N = int(i[0])
ans=0
for s in range(N-1):
if i[1+s]==0:
continue
cul= int((i[1+s]+i[2+s])/2)
ans += cul
if i[1+s]>i[2+s]:
amari = (i[1+s]+i[2+s])%2
print(ans)
|
s705445632 | p04020 | u620944332 | 1471838173 | Python | Python (3.4.3) | py | Runtime Error | 576 | 7832 | 390 | # -*- coding: utf-8 -*-
import math
from functools import reduce
if __name__ == '__main__':
n = int(input())
a = []
ans = 0
for i in range(n):
tmp = int(input())
a.append(tmp)
if tmp == 0:
ans += math.floor(reduce(lambda x, y: x + y, a) // 2)
a.clear()
ans += math.floor(reduce(lambda x, y: x + y, a) // 2)
print(ans)
|
s035432278 | p04020 | u471797506 | 1471833968 | Python | Python (2.7.6) | py | Runtime Error | 26 | 2568 | 871 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<typename T> using Graph = vector<vector<T>>;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (__typeof(a.begin()) x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define endl '\n'
int N;
int A[100005];
int main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N;
ll ans = 0;
rep(i, N) cin >> A[i];
rep(i, N) {
if (A[i]%2 && A[i + 1] > 0) {
ans += 1;
A[i] -= 1;
A[i + 1] -= 1;
}
}
rep(i, N) {
ans += A[i]/2;
A[i] %= 2;
}
rep(i, N) {
ll mn = min(A[i], A[i + 1]);
ans += mn;
A[i] -= mn;
A[i + 1] -= mn;
}
cout << ans << endl;
return 0;
}
|
s744122039 | p04020 | u921066423 | 1471831816 | Python | Python (2.7.6) | py | Runtime Error | 29 | 2692 | 421 | N = int(raw_input())
A = [0] * 1000000100
# A = [0] * 10
for i in xrange(N):
A[i] = int(raw_input())
tmp = A[0]
sum_v = 0
sum_v += (tmp/2)
tmp = (A[0]%2)
min_v = 0
for i in xrange(1,N):
if ((tmp/2) > 0):
sum_v += (tmp/2)
tmp = (tmp%2)
if (A[i] > 0 and tmp > 0):
min_v = min(A[i],tmp)
sum_v += min_v
if (min_v == A[i]):
A[i] = 0
else:
A[i] = A[i] - tmp
tmp = A[i]
sum_v += (A[N-1] / 2)
print sum_v
|
s350846989 | p04021 | u888092736 | 1599152523 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 20232 | 747 | class FenwickTree:
def __init__(self, n):
self.n = n
self.data = [0] * (n + 1)
self.k_init = 2 ** (self.n - 1).bit_length()
def sum(self, i):
s = 0
while i > 0:
s += self.data[i]
i -= i & -i
return s
def add(self, i, x):
while i <= self.n:
self.data[i] += x
i += i & -i
def get_invnum(li):
n = len(li)
t = FenwickTree(max(li))
res = 0
for i in range(n):
res += i - t.sum(li[i])
t.add(li[i], 1)
return res
N, *A = map(int, open(0).read().split())
triplet_sorted_A = [0] * N
triplet_sorted_A[::2] = sorted(A[::2])
triplet_sorted_A[1::2] = sorted(A[1::2])
print(get_invnum(triplet_sorted_A))
|
s244155637 | p04021 | u327466606 | 1598663257 | Python | PyPy3 (7.3.0) | py | Runtime Error | 215 | 81880 | 187 | from bisect import bisect_left
N = int(input())
A = list(int(input()) for _ in range(N))
S = sorted(S)
A = [bisect_left(S,a) for a in A]
print((sum((i-j)%2 for i,j in enumerate(A))+1)//2) |
s157512540 | p04021 | u225388820 | 1596566419 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9040 | 210 | from collections import Counter
n=int(input())
a=[int(input()) for i in range(n)]
b=Counter(a[::2])
a.sort()
c=Counter(a[::2])
ans=0
for i in b:
if i in c:
ans+=abs(b[i])-c[i])
else:
ans+=b[i]
print(ans) |
s484938121 | p04021 | u225388820 | 1596552935 | Python | Python (3.8.2) | py | Runtime Error | 170 | 14380 | 220 | n=int(input())
a=[int(input()) for i in range(n)]
b=a[::2]
c=a[1::2]
b.sort()
c.sort()
a=[c[i] if i&1 else b[i] for i in range(n)]
cnt=0
for i in range(n-1):
if a[i]>a[i+1]:
cnt+=1
a[i],a[i+1]=a[i+1],a[i]
print(cnt) |
s143844452 | p04021 | u225388820 | 1596552896 | Python | Python (3.8.2) | py | Runtime Error | 26 | 8920 | 219 | n=int(input())
a=[int(input() for i in range(n)]
b=a[::2]
c=a[1::2]
b.sort()
c.sort()
a=[c[i] if i&1 else b[i] for i in range(n)]
cnt=0
for i in range(n-1):
if a[i]>a[i+1]:
cnt+=1
a[i],a[i+1]=a[i+1],a[i]
print(cnt) |
s860819863 | p04021 | u588794534 | 1591754811 | Python | PyPy3 (2.4.0) | py | Runtime Error | 179 | 38640 | 202 | n=int(input())
ans=0
a=[]
b=[]
for _ in range():
x=int(input())
a.append(x)
b.append(x)
b.sort()
cnt=0
for i,v in enumerate(a):
if i%2 != (b.index(v))%2:
cnt+=1
print(cnt//2) |
s013579291 | p04021 | u588794534 | 1591754597 | Python | PyPy3 (2.4.0) | py | Runtime Error | 517 | 49240 | 162 | n=int(input())
ans=0
a=[int(input()) for _ in range(n)]
b=a.sorted()
cnt=0
for i,v in enumerate(a):
if i%2 != (b.index(b))%2:
cnt+=1
print(cnt//2) |
s585376715 | p04021 | u488401358 | 1587832959 | Python | PyPy3 (2.4.0) | py | Runtime Error | 529 | 49240 | 247 | N=int(input())
A=[]
for i in range(N):
A.append(int(input()))
a=A.copy()
A.sort()
dic={}
for i in range(0,N):
dic[a[i]]=0
dic[a[i]]=i
ans=0
for i in range(0,N):
if i%2==1:
if dic[A[i]]%2==0:
ans+=1
print(ans) |
s369612196 | p04021 | u476604182 | 1583547424 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 169 | N, *A = map(int, open('0').read().split())
ans = 0
B = sorted(A)
dic = {B[i]:i for i in range(N)}
for i,n in enumerate(A):
if i%2!=dic[n]%2:
ans += 1
print(ans//2) |
s087547862 | p04021 | u358254559 | 1582997634 | Python | PyPy3 (2.4.0) | py | Runtime Error | 509 | 49240 | 197 | n = int(input())
a = []
for _ in range(n):
a.append(int(input()))
import numpy as np
lis = np.argsort(np.array(a))
ans=0
for i in range(n):
if i%2 != lis[i]%2:
ans+=1
print(ans//2) |
s170769382 | p04021 | u600402037 | 1577978845 | Python | Python (3.4.3) | py | Runtime Error | 168 | 19876 | 399 | import sys
#import numpy as np
stdin = sys.stdin
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip() # ignore trailing spaces
N = ri()
A = [ri() for _ in range(N)]
x_to_i = {x:i for i, x in enumerate(sorted(A))}
rank = [x_to_i[x] for x in A]
answer = sum((i^x)&1 for i,x in enumerate(rank)) // 2
print(B)
|
s739946121 | p04021 | u600402037 | 1577966395 | Python | Python (3.4.3) | py | Runtime Error | 282 | 21124 | 399 | import sys
import numpy as np
stdin = sys.stdin
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip() # ignore trailing spaces
N = ri()
A = [ri() for _ in range(N)]
B = sorted(np.array(A))
C = [np.where(B == a)[0][0] for a in A]
answer = sum([i%2==1 and x%2!=1 for i, x in enumerate(C)])
print(answer)
# 41
|
s759460742 | p04021 | u672220554 | 1570728907 | Python | Python (3.4.3) | py | Runtime Error | 213 | 7288 | 809 | def main():
n = int(input())
a=[]
b=[]
if n == 1:
a=int(input())
print(0)
else:
for i in range(n//2):
a.append(int(input()))
b.append(int(input()))
if n % 2 == 1:
a.append(int(input()))
a.sort()
b.sort()
ta=a[0]
tb=b[0]
if ta < tb:
res = 0
else:
tb = ta
res = 1
for i in range(1,n//2+1):
if a[i] < tb:
ta = tb
res += 1
else:
ta = a[i]
if b[i] < ta:
tb =ta
res += 1
else:
tb = b[i]
if n % 2 == 1:
if a[-1] < tb:
res += 1
print(res)
main() |
s835575840 | p04021 | u736729525 | 1568942831 | Python | Python (3.4.3) | py | Runtime Error | 306 | 16944 | 177 | N = int(input())
A = [0]*N
r = 0
for i in range(N):
a = int(input())
A[i] = (a, i)
A.sort()
cnt = 0
for i in range(N, 2):
a, j = A[i]
cnt += j & 1
print(cnt)
|
s461838320 | p04021 | u892251744 | 1567178646 | Python | PyPy3 (2.4.0) | py | Runtime Error | 557 | 48088 | 785 | N = int(input())
A = [0] * N
for i in range(N):
A[i] = int(input()) + 1
A_even = A[::2]
A_odd = A[1::2]
A_even = sorted(A_even)
A_odd = sorted(A_odd)
A_sorted = [0] * N
for i in range(N):
if i % 2 == 0:
A_sorted[i] = A_even[i // 2]
else:
A_sorted[i] = A_odd[i // 2]
class Bit:
def __init__(self, n):
self.size = n
self.tree = [0] * (n + 1)
def sum(self, idx):
s = 0
while idx > 0:
s += self.tree[idx]
idx -= idx & -idx
return s
def add(self, idx, x):
while idx <= self.size:
self.tree[idx] += x
idx += idx & -idx
bit = Bit(max(A) + 1)
ans = 0
for i in range(N):
bit.add(A_sorted[i], 1)
ans += i + 1 - bit.sum(A_sorted[i])
print(ans)
|
s983093709 | p04021 | u892251744 | 1567177871 | Python | PyPy3 (2.4.0) | py | Runtime Error | 581 | 48088 | 781 | N = int(input())
A = [0] * N
for i in range(N):
A[i] = int(input()) + 1
A_even = A[::2]
A_odd = A[1::2]
A_even = sorted(A_even)
A_odd = sorted(A_odd)
A_sorted = [0] * N
for i in range(N):
if i % 2 == 0:
A_sorted[i] = A_even[i // 2]
else:
A_sorted[i] = A_odd[i // 2]
class Bit:
def __init__(self, n):
self.size = n
self.tree = [0] * (n + 1)
def sum(self, idx):
s = 0
while idx > 0:
s += self.tree[idx]
idx -= idx & -idx
return s
def add(self, idx, x):
while idx <= self.size:
self.tree[idx] += x
idx += idx & -idx
bit = Bit(max(A))
ans = 0
for i in range(N):
bit.add(A_sorted[i], 1)
ans += i + 1 - bit.sum(A_sorted[i])
print(ans)
|
s976255478 | p04021 | u892251744 | 1567177723 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2106 | 49664 | 777 | N = int(input())
A = [0] * N
for i in range(N):
A[i] = int(input())
A_even = A[::2]
A_odd = A[1::2]
A_even = sorted(A_even)
A_odd = sorted(A_odd)
A_sorted = [0] * N
for i in range(N):
if i % 2 == 0:
A_sorted[i] = A_even[i // 2]
else:
A_sorted[i] = A_odd[i // 2]
class Bit:
def __init__(self, n):
self.size = n
self.tree = [0] * (n + 1)
def sum(self, idx):
s = 0
while idx > 0:
s += self.tree[idx]
idx -= idx & -idx
return s
def add(self, idx, x):
while idx <= self.size:
self.tree[idx] += x
idx += idx & -idx
bit = Bit(max(A))
ans = 0
for i in range(N):
bit.add(A_sorted[i], 1)
ans += i + 1 - bit.sum(A_sorted[i])
print(ans)
|
s454333119 | p04021 | u102461423 | 1567095379 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 332 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
I,O,T,J,L,S,Z = map(int,input().split())
# T,S,Z は無関係
# I,O,J,Lに注目
# Oは足すだけ
# I,J,Lが問題
# II, JIL, JJ, LL
x = (I//2 + J//2 + L//2) * 2
if I>0 and J>0 and L>0:
x = max(x,((I-1)//2 + (J-1)//2 + (L-1)//2) * 2 + 3)
x += O
print(x) |
s966650398 | p04021 | u201234972 | 1560719671 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 405 | #import sys
#from collections import defaultdict
input = sys.stdin.readline
def main():
N = int( input())
A = [ int( input()) for _ in range(N)]
B = sorted(A)
d = defaultdict( int)
for i in range(N):
d[B[i]] = i
odd = 0
for i in range(N):
if (i+1)%2 == d[A[i]]%2 and d[A[i]]%2 == 1:
odd += 1
print(odd)
if __name__ == '__main__':
main() |
s732435351 | p04021 | u201234972 | 1560719660 | Python | PyPy3 (2.4.0) | py | Runtime Error | 174 | 38640 | 405 | #import sys
#from collections import defaultdict
input = sys.stdin.readline
def main():
N = int( input())
A = [ int( input()) for _ in range(N)]
B = sorted(A)
d = defaultdict( int)
for i in range(N):
d[B[i]] = i
odd = 0
for i in range(N):
if (i+1)%2 == d[A[i]]%2 and d[A[i]]%2 == 1:
odd += 1
print(odd)
if __name__ == '__main__':
main() |
s818999899 | p04021 | u360090862 | 1560363843 | Python | Python (3.4.3) | py | Runtime Error | 245 | 8932 | 252 | N=int(input())
A=[]
B=[]
for i in range(N):
if i%2==0:
A.append(int(input()))
else:
B.append(int(input()))
A=sorted(A)
B=sorted(B)
C=sorted(A+B)
#ここまでNlogN
c=0
j=0
for i in range(C):
if A[j]==C[i]:
if i%2==1:
c+=1
j+=1
print(c) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.