Problem:


Score : 400 points

Problem Statement

Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it.
He has A_i cards with an integer i.

Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.

Snuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.

Constraints

1 ≦ N ≦ 10^5

0 ≦ A_i ≦ 10^9 (1 ≦ i ≦ N)

All input values are integers.

Input

The input is given from Standard Input in the following format:

N
A_1
:
A_N

Output

Print the maximum number of pairs that Snuke can create.

Sample Input 1

4
4
0
3
2

Sample Output 1

4

For example, Snuke can create the following four pairs: (1,1),(1,1),(3,4),(3,4).

Sample Input 2

8
2
0
1
6
0
8
2
1

Sample Output 2

9



Sample input:
4
4
0
3
2


Sample output:
4

Submission status: Wrong Answer

Solution code:
N=int(input())
pre=int(input())
ans=pre//2
pre=pre&1
for i in range(2,N+1):
    Ai=int(input())
    ans+=Ai//2
    if pre and Ai&1:
        ans+=1
        pre=0
    else:
        pre=Ai&1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = [int(input()) for _ in range(n)]
B = [0]*(n+1)
ans = 0
for i in range(n):
  q, r = divmod(A[i]+B[i], 2)
  ans += q
  if r:
    B[i+1] += A[i]%2
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    ans = 0
    L = [0]
    for i in range(N):
        num = int(input())
        ans += num//2
        rest = num%2
        if (L[-1] == 1 and rest == 1):
            ans += 1
            L.append(0)
        else:
            L.append(rest)
            
    print(ans)
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[]
for _ in range(N):
    A.append(int(input()))

sum_=0
for i in range(N):
    sum_ += A[i] // 2
    A[i] = A[i] % 2

sum2=0
for i in range(N-1):
    if A[i] == 1 and A[i+1] == 1:
        sum2 += 1
        A[i] = 0
        A[i+1] = 0
print(sum_+sum2)

Submission status: Wrong Answer

Solution code:
N = int(input())
res = 0
l = [0 for i in range(N)]
for i in range(N):
    l[i] = int(input())
    if i > 0 and l[i] % 2 == l[i - 1] % 2 == 1:
        res += 1
        l[i] -= 1
    res += l[i] // 2
print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
res = 0
l = [0 for i in range(N)]
for i in range(N):
    l[i] = int(input())
    res += l[i] // 2
    if i > 0 and l[i] % 2 == l[i - 1] % 2 == 1:
        res += 1
        l[i] -= 1
print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]

ans = 0
for i in range(N):
    ans += A[i] // 2
    A[i] %= 2

for i in range(N-1):
    if A[i] == 1 and A[i+1] == 1:
        ans += 1
        A[i] = 0
        A[i+1] = 0
print(ans)

Submission status: Wrong Answer

Solution code:
# ババ抜きと同じ要領で解く
N = int(input())
ans = 0
flag = False
for _ in range(N):
    a = int(input())
    ans += a//2
    if flag and a % 2 == 1:
        ans += 1
    a -= 1
    if a % 2 == 1:
        flag = True
    else:
        flag = False
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())  # 1からNまでの整数をもっていて、
value_amout = {}
ans = 0
for i in range(1, N+1):
    a = int(input())
    ans += (a//2)
    value_amout[i] = (a % 2)
# print(value_amout)
# ans = 0
# for i in range(1, N+1):
#     ans += value_amout[i] // 2
#     value_amout[i] = value_amout[i] % 2

for i in range(1, N):
    if value_amout[i] == 1 and value_amout[i+1] == 1:
        ans += 1
        value_amout[i] = 0
        value_amout[i+1] = 0
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())  # 1からNまでの整数をもっていて、
value_amout = {}
for i in range(1, N+1):
    a = int(input())
    value_amout[i] = a
# print(value_amout)
ans = 0
for i in range(1, N+1):
    ans += value_amout[i] // 2
    value_amout[i] = value_amout[i] % 2

for i in range(1, N):
    if value_amout[i] == 1 and value_amout[i+1] == 1:
        ans += 1
        value_amout[i] = 0
        value_amout[i+1] = 0
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
import sys
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
    
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])


def main():
    n=inp()
    a=inplm(n)
    ans = 0
    for i in range(n-1):
        x = min(a[i],a[i+1])
        ans += x
        a[i] -= x
        a[i+1] -= x
        ans += a[i]//2
    ans += a[n-1]//2
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[0]*N
DP=[0]*(N+1)

for i in range(N):
    A[i]=int(input())

if N==1:
    print(A[0]//2)
    exit()
elif N==2:
    print(max(A[0]//2+A[1]//2,min(A[0],A[1])))
    exit()
DP[0]=0
DP[1]=A[0]//2
DP[2]=max(A[0]//2+A[1]//2,min(A[0],A[1]))
DP[3]=max(A[0]//2+A[1]//2+A[2]//2,A[0]//2+min(A[1],A[2]),A[1]//2+min(A[2],A[0]),A[2]//2+min(A[1],A[0]))

for i in range(4,N+1):
    ans1=DP[i-4]+A[i-4]//2+A[i-3]//2+A[i-2]//2+A[i-1]//2
    ans2=DP[i-4]+A[i-4]//2+min(A[i-3],A[i-2])+A[i-1]//2
    ans3=DP[i-4]+A[i-4]//2+A[i-3]//2+min(A[i-2],A[i-1])
    ans4=DP[i-4]+min(A[i-4],A[i-3])+A[i-2]//2+A[i-1]//2
    ans5=DP[i-4]+min(A[i-4],A[i-3])+min(A[i-2],A[i-1])
    DP[i]=max(ans1,ans2,ans3,ans4,ans5)

print(DP[N])

Submission status: Wrong Answer

Solution code:
N=int(input())
DP=[0]*N

A=int(input())
DP[0]=A//2

for i in range(1,N):
    A0=A
    A=int(input())
    DP[i]=max(DP[i-1]+A//2,min(A0,A))

print(DP[N-1])

Submission status: Wrong Answer

Solution code:
n = int(input())
A = [int(input()) for _ in range(n)]

prev_mod = 0
ans = 0
for a in A:
    ans += a // 2
    mod = a % 2
    if mod+prev_mod == 2:
        ans += 1
        mod = 0
    prev_mod = mod

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]

ret = 0
for i in range(N) :
    if A[i] > 2 :
        x = (A[i] - 2) // 2
        ret += x
        A[i] -= x * 2

for _ in range(2) :
    for i in range(N - 1) :
        if A[i] >= 1 and A[i + 1] >= 1 :
            ret += 1
            A[i] -= 1
            A[i + 1] -= 1

for i in range(N) :
    if A[i] >= 2 :
        ret += 1
    
print(ret)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]

ret = 0
for i in range(N) :
    if A[i] > 2 :
        x = (A[i] - 2) // 2
        ret += x
        A[i] -= x * 2

for i in range(N - 1) :
    if A[i] >= 1 and A[i + 1] >= 1 :
        x = min(A[i], A[i + 1])
        ret += x
        A[i] -= x
        A[i + 1] -= x
        
for i in range(N) :
    if A[i] >= 2 :
        ret += 1
    
print(ret)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)

N = int(input())
A = [int(input()) for _ in range(N)]

ret = 0
for i in range(N) :
    if A[i] > 2 :
        x = (A[i] - 1) // 2
        ret += x
        A[i] -= x * 2

for i in range(N - 1) :
    if A[i] >= 1 and A[i + 1] >= 1 :
        x = min(A[i], A[i + 1])
        ret += x
        A[i] -= x
        A[i + 1] -= x
        
ret += A.count(2)
    
print(ret)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)

N = int(input())
A = [int(input()) for _ in range(N)]

ret = 0
for i in range(N) :
    if A[i] > 2 :
        x = (A[i] - 1) // 2
        ret += x
        A[i] -= x * 2

for i in range(N - 1) :
    if A[i] >= 1 or A[i + 1] >= 1 :
        x = min(A[i], A[i + 1])
        ret += x
        A[i] -= x
        A[i + 1] -= x
        
ret += A.count(2)
    
print(ret)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)

N = int(input())
A = [int(input()) for _ in range(N)]

ret = 0
for i in range(N) :
    ret += A[i] // 2
    A[i] %= 2
    
i = 0
while i < N - 1 :
    if A[i] and A[i + 1] :
        ret += 1
        i += 1
    i += 1
    
print(ret)

Submission status: Wrong Answer

Solution code:
N=int(input())
ans=0
re=0
for _ in range(N):
  a=int(input())
  if a%2==0:
    ans+=a//2
    if a==0:
      re=0
  else:
    if re==1:
      ans+=a//2+1
      re=0
    else:
      ans+=a//2
      re=0
      
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
ans=0
re=0
for _ in range(N):
  a=int(input())
  if a%2==0:
    ans+=a//2
  else:
    if re==1:
      ans+=a//2+1
      re=0
    else:
      ans+=a//2
      re=0
      
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
ans=0
re=0
for _ in range(N):
  a=int(input())
  if a%2==0:
    ans+=a//2
    re=0
  else:
    if re==1:
      ans+=a//2+1
      re=0
    else:
      ans+=a//2
      re=0
      
print(ans)

Submission status: Wrong Answer

Solution code:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = [int(readline()) for _ in range(n)]
    c = ac = 0
    for v in a:
        c += v
        if v != 0:
            ac += c // 2
            c = 0
    print(ac + c // 2)


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

n=int(input())
l=[int(input()) for _ in range(n)]
ans=0
re=0
for i in l:
    if i==0:
        re=0
    ans+=(i+re)//2
    re=i%2
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[0]
for i in range(n):
  l.append(int(input()))
count=0
for i in range(n-1):
  if l[i]%2==1 and l[i+1]>0:
    count+=1
    l[i]-=1
    l[i+1]-=1
for i in range(n):
  count+=l[i]//2
print(count)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[0]
for i in range(n):
  l.append(int(input()))
count=0
for i in range(1,n):
  m=min(l[i-1],l[i])
  count+=m
  l[i-1]-=m
  l[i]-=m
for i in range(n):
  count+=l[i]//2
print(count)

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=0
check=0
for i in range(n):
  s=int(input())
  if i==n-1:
    check+=s
    ans+=check//2
  elif s!=0:
    check+=s
  else:
    ans+=check//2
    check=0
print(check)

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=0
check=0
for i in range(n):
  s=int(input())
  if i==n-1:
    check+=s
    ans+=check//2
  elif s!=0:
    check+=s
  else:
    ans+=check//2
    check=0
print(check)

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = [0] * (N + 1)
    cnt = 0
    for i in range(N):
        A[i] = int(input())
        cnt += A[i] // 2
        A[i] = A[i] % 2
 
    for i in range(N):
        if A[i] > 0 and A[i+1] > 0:
            cnt += 1
            A[i] -= 1
            A[i+1] -= 1
 
    print(cnt)
 
 
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = [0] * (N + 1)
    cnt = 0
    for i in range(N):
        tmp = int(input())
        cnt += tmp // 2
        A[i] = tmp % 2

    for i in range(N):
        if A[i] > 0 and A[i+1] > 0:
            cnt += 1
            A[i] -= 1
            A[i+1] -= 1
 
    print(cnt)
 
 
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = [0] * N
    cnt = 0
    for i in range(N):
        tmp = int(input())
        cnt += tmp // 2
        A[i] = tmp % 2

    i = 0
    while i < N - 1:
        if A[i] == 1 and A[i+1] == 1:
            cnt += 1
            i += 2
        else:
            i += 1

    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]

ans = 0
i = 0
while i < N - 1:
    if A[i] < A[i + 1]:
        ans += A[i]
        A[i + 1] -= A[i]
        A[i] = 0
        i += 1
    else:
        ans += A[i + 1]
        A[i] -= A[i + 1]
        A[i + 1] = 0
        ans += A[i] // 2
        i += 2
print(ans)

Submission status: Wrong Answer

Solution code:
#絶対値1「以下」、同じでよい
#1枚または2枚だけ残して取る
#貪欲の手順がおかしかった
#同一ペアを組むのはそれ以下の数を除いた後
#editorial参照、さらに単純に0で区切ってn//2になる
n = int(input())
a = []
for _ in range(n):
    a_ = int(input())
    a.append(a_)
#print(a)
ans = 0
"""
for i in range(n-1):
    if a[i]&1:
        ans += a[i]//2
        a[i] = 1
    elif a[i] ==0:
        pass
    else:
        ans += a[i]//2-1
        a[i] = 2
print(a)
print(ans)
"""
for i in range(n-1):
    ans += a[i]//2
    a[i] -= (a[i]//2)*2
    ad = min(a[i],a[i+1])
    ans += ad
    a[i+1] -= ad
print(ans)

Submission status: Wrong Answer

Solution code:
#絶対値1「以下」、同じでよい
#1枚または2枚だけ残して取る
n = int(input())
a = []
for _ in range(n):
    a_ = int(input())
    a.append(a_)

ans = 0

for i in range(n-1):
    if a[i]&1:
        ans += a[i]//2
        a[i] = 1
    elif a[i] ==0:
        pass
    else:
        ans += a[i]//2-1
        a[i] = 2

for i in range(n-1):
    if a[i] == 2:
        ans += 1
        a[i] = 0
    else:
        ad = min(a[i],a[i+1])
        ans += ad
        a[i+1] -= ad
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
aa = [int(input()) for _ in range(n)]

count = 0
for i in range(n-1):
  count += aa[i]//2
  aa[i] = aa[i]%2
  if aa[i] % 2 == 1 and aa[i+1]>0 :
    aa[i+1] -= 1
    aa[i] -= 1
    count+=1      

print(count)

Submission status: Wrong Answer

Solution code:
a=[0]
n=int(input())
for i in range(0,n):
    pai=int(input())
    a.append(pai)
ans=0
for i in range(0,n):
    ans=ans+a[i]//2
    a[i]=a[i]%2
    if a[i]>0 and a[i+1]>0:
        ans=ans+1
        a[i]=a[i]-1
        a[i+1]=a[i+1]-1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]

ans = 0
for i in range(N):
  if i < N-1:
    m = min(A[i],A[i+1])
    ans += m
    A[i] -= m
    A[i+1] -= m
  if A[i] >= 2:
    ans += A[i]//2
    A[i] -= (A[i]//2)*2
  #print(i,ans,A)
print(ans)

Submission status: Wrong Answer

Solution code:
#B - Simplified mahjong
n=int(input())
modlists=[0]*(n+1)
for  i in range(n):
    s=int(input())
    modlists[i]=s
add=0
for i in range(n):
    ch=min(modlists[i],modlists[i+1])
    add+=ch
    modlists[i]-=ch
    modlists[i+1]-=ch
for i in range(n):
    add+=modlists[i]//2
print(add)

Submission status: Wrong Answer

Solution code:
#B - Simplified mahjong
n=int(input())
modlists=[0]*n
counter=0
for  i in range(n):
    s=int(input())
    a,b=divmod(s,2)
    counter+=a
    modlists[i]=b


add=0
modlists.append(0)
for i in range(n+1):
    if modlists[i]==1:
        add+=1
    else:
        counter+=add//2
        add=0
print(counter)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.buffer.readline
N = int(input())
a = [int(input()) for _ in range(N)]
res = 0
for i in range(N):
  res += a[i] // 2
  a[i] %= 2
for i in range(N - 1):
  if a[i] > 0 and a[i + 1] > 0:
    t = min(a[i], a[i + 1])
    a[i] -= t
    a[i + 1] -= t
    res += t
print(res)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.buffer.readline
N = int(input())
a = [int(input()) for _ in range(N)]
res = 0
for i in range(N - 1):
  if a[i] > 0 and a[i + 1] > 0:
    t = min(a[i], a[i + 1])
    a[i] -= t
    a[i + 1] -= t
    res += t
  res += a[i] // 2
res += a[-1] // 2
print(res)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

N = int(input().split()[0])
a_list = []

for _ in range(N):
    a = int(input().split()[0])
    a_list.append(a)

c = 0

for i in range(N):
    before = a_list[i - 1] if i != 0 else 0

    if (before + a_list[i]) % 2 == 0:
        c += a_list[i] // 2
        a_list[i] = 0
    else:
        c += a_list[i] // 2
        a_list[i] = a_list[i] % 2
ans = c
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]
m = 0
ans = 0
for i in A:
  num = i + m
  d = num // 2
  if num % 2 == 1 and i % 2 == 1:
    m = 1
  else:
    m = 0
  ans += d
#  print(d, m, ans)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]
m = 0
ans = 0
for i in A:
  num = i + m
  d = num // 2
  if i % 2 == 0:
    m = 0
  else:
    m = 1
  ans += d
#  print(d, m, ans)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]

ans = 0

for i in range(N-1):
    tmp = min(A[i], A[i+1])
    A[i] -= tmp
    A[i+1] -= tmp
    ans += tmp

for a in A:
    ans += a // 2

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]

ans = 0

for i, a in enumerate(A):
    ans += a // 2
    A[i] = a % 2

for i in range(N-1):
    if A[i] == A[i+1] == 1:
        ans += 1
        A[i] = 0
        A[i+1] = 0

print(ans)

Submission status: Wrong Answer

Solution code:
#y,m,d=map(int,input().split())
#a,b=map(int,input().split())
n=int(input())
#a=int(input())
#b=int(input())
#s=list(input())
#T=input()
#recipe=[list(input().split())for _ in range(n)]
#m=int(input())
#have=[list(input().split())for _ in range(m)]
#s=[list(input())for _ in range(n)]
#b=list(map(int,input().split()))
#b=list(map(int,input().split()))
#a=list(map(int,input().split()))
#c=list(map(float,input().split()))
#n=int(input())
#s=[list(map(int,input().split()))for _ in range(n)]
#a=[list(input().split())for _ in range(n)]
a=[int(input())for _ in range(n)]
ans=0
total=0
judge=False
for i in range(n):
    total+=a[i]
    if a[i]==0:
        ans+=total//2
        total=0
        judge=True
if judge:
    print(ans+total//2)
else:
    print(n//2)

Submission status: Wrong Answer

Solution code:
#y,m,d=map(int,input().split())
#a,b=map(int,input().split())
n=int(input())
#a=int(input())
#b=int(input())
#s=list(input())
#T=input()
#recipe=[list(input().split())for _ in range(n)]
#m=int(input())
#have=[list(input().split())for _ in range(m)]
#s=[list(input())for _ in range(n)]
#b=list(map(int,input().split()))
#b=list(map(int,input().split()))
#a=list(map(int,input().split()))
#c=list(map(float,input().split()))
#n=int(input())
#s=[list(map(int,input().split()))for _ in range(n)]
#a=[list(input().split())for _ in range(n)]
a=[int(input())for _ in range(n)]
ans=0
extra=[]
for i in range(n):
    ans+=a[i]//2
    if a[i]%2==1:
        extra.append(i+1)
if len(extra)!=0:
    extra.sort()
    for i in range(len(extra)-1):
        if extra[i]+1==extra[i+1]:
            ans+=1
            extra[i+1]=-100
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(input()) for i in range(n)]

ans=0
li=[0]*n
ans+=a[0]//2
li[0]=(a[0]%2)
for i in range(1,n):
    ans+=a[i]//2
    if a[i]%2 !=0 and li[i-1]==1:
        ans+=1
    elif a[i]%2 != 0:
        li[i]=1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

#(方針)同じ数でペアを作りまくる → 残りで隣の数とペアを作れるか
ans = 0
counter = []
for i in range(N):
  a = int(input())
  b = a//2
  ans += b
  counter.append([i,a-2*b])
 
for i in range(N):
  if(i != N-1):
    if((counter[i][1] == 1)and(counter[i+1][1]==1)):
      ans += 1
      counter[i][1] = 0
      counter[i+1][1] = 0
print(ans)

Submission status: Wrong Answer

Solution code:
def resolve():
    n = int(input())
    a = list(int(input()) for _ in range(n))
    ans = 0
    for i in range(n):
        ans += a[i] // 2
        if i != n - 1 and a[i] % 2 and a[i + 1] % 2:
            ans += 1
            a[i + 1] -= 1
    print(ans)


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline

n=int(input())
a=[int(input()) for _ in range(n)]
ans=0
for i in range(n-1):
    ans+=(a[i]+a[i+1])//2
    a[i+1]=min(a[i+1],(a[i]+a[i+1])%2)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline

n=int(input())
a=[int(input()) for _ in range(n)]
ans=0
for i in range(n-1):
    ans+=(a[i]+a[i+1])//2
    a[i+1]=min(0,(a[i]+a[i+1])%2)

print(ans)

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=[0]*(n+1)

  l2=[I() for _ in range(n)]

  ans=0

  for i,x in enumerate(l2):
    l[i+1]=x%2
    x+=l[i]
    ans+=x//2
  return ans

# main()
print(main())

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[0 for i in range(n+1)]
ans=0
for i in range(1,n+1):
    tmp=int(input())
    ans+=tmp//2
    if tmp%2==1:
        if l[i-1]==1:
            ans+=1
        else:l[i]=1
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[int(input()) for i in range(N)]

if N==1:
    print(0)
    exit()

DP=[0]*N

DP[0]=A[0]//2

DP[1]=max(DP[0]+A[1]//2,min(A[0:2]))

for i in range(2,N):
    DP[i]=max(DP[i-1]+A[i]//2,DP[i-2]+min(A[i-1],A[i]))


print(DP[N-1])

Submission status: Wrong Answer

Solution code:
N=int(input())

if N==1:
    print(0)
    exit()

DP=[0]*N

a0=int(input())
DP[0]=a0//2

a=int(input())
DP[1]=max(DP[0]+a//2,min(a0,a))

a0=a

for i in range(2,N):
    a=int(input())
    DP[i]=max(DP[i-1]+a//2,DP[i-2]+min(a0,a))
    a0=a

print(DP[N-1])

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
A = IR(n)
ans = 0
cur = 0
for i in range(n):
    if not A[i]:
        cur = 0
    else:
        if cur % 2:
            ans += 1
            A[i] -= 1
        ans += A[i] // 2


print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]

count=0

"""
for i in range(n):
    count+=a[i]//2
    a[i]=a[i]%2
"""

for i in range(n-1):
    while((a[i]>0) & (a[i+1]>0)):
        MinNum=min(a[i],a[i+1])
        a[i]-=MinNum
        a[i+1]-=MinNum
        count = count+MinNum
    count+=a[i]//2
    a[i]=a[i]%2

count+=a[n-1]//2
a[n-1]=a[n-1]%2

print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]

count=0

"""
for i in range(n):
    count+=a[i]//2
    a[i]=a[i]%2
"""

for i in range(n-1):
    while(a[i]>1 & a[i+1]>1):
        a[i]-=1
        a[i+1]-=1
        count = count+1

for i in range(n):
    count+=a[i]//2
    a[i]=a[i]%2

print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]

count=0

for i in range(n):
    count+=a[i]//2
    a[i]=a[i]%2

for i in range(n-1):
    if(a[i]==1 & a[i+1]==1):
        a[i]=0
        a[i+1]=0
        count = count+1

print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]

count=0

for i in range(n):
    count+=a[i]//2
    a[i]=a[i]%2

for i in range(n-1):
    if(a[i]==1 & a[i+1]==1):
        a[i]=0
        a[i+1]=0
        count+1

print(count)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=0
b=int(input())
for i in range(n-1):
  c=int(input())
  t=(b+c)//2
  a+=t
  b=c-max(0,t*2-b)
print(a)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
for i in range(n):
	x=int(input())
	a.append(x)
ans=0
for i in range(n-1):
	if a[i]>0:
		ans+=(a[i]//2)
		a[i]-=(a[i]//2)*2
	if a[i]>0:
		a[i+1]-=min(a[i],a[i+1])
		ans+=min(a[i],a[i+1])
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]
ans = 0
for i in range(N):
  if i == N-1:
    ans += A[i]//2
  else:
    if A[i] == 0:
      pass
    elif A[i+1] == 0:
      ans += A[i]//2
    else:
      Min = min(A[i],A[i+1])
      ans += Min
      A[i] -= Min
      A[i+1] -= Min
      if A[i] > 1:
        ans += A[i]//2
  #print(i,A,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]
ans = 0
for i in range(N):
  if i == N-1:
    ans += A[i]//2
  else:
    if A[i] == 0:
      pass
    elif A[i] >= 2 and A[i+1] == 0:
      ans += A[i]//2
    elif A[i] > 0 and A[i+1] > 0:
      Min = min(A[i],A[i+1])
      ans += Min
      A[i] -= Min
      A[i+1] -= Min
      if A[i] > 1:
        ans += A[i]//2
  #print(i,A,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = LIST(N)

ans = A[0] // 2
mod = A[0] % 2
for i in range(1, N):
    ans += A[i] // 2
    tmpmod = A[i] % 2
    if mod == tmpmod == 1:
        ans += 1
        mod = 0
    elif tmpmod == 1:
        mod = 1
    elif mod == 1:
        mod = 0
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]
res = 0
if n == 1:
    print(a[0] // 2)
else:
    for i in range(0, n - 1):
        res += a[i] // 2
        if i != n - 1 and a[i] % 2 == 1 and a[i + 1] != 0:
            res += 1
            a[i + 1] -= 1
    print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]
res = 0
if n == 1:
    print(a[0] // 2)
else:
    for i in range(0,n-1):
        if a[i] == 0:
            continue
        elif a[i] <= a[i+1]:
            res += a[i]
            a[i+1]-= a[i]
        else:
            if a[i] %2 == 1:
                res += 1
                a[i] -= 1
                a[i+1] -= 1
            pair = a[i+1] // 2
            res += pair * 2
            res += (a[i]- pair) //2
            a[i+1] -= pair * 2

    print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]
res = 0
if n == 1:
    print(a[0] // 2)
else:
    for i in range(0,n-1):
        if a[i] == 0:
            continue
        elif a[i] <= a[i+1]:
            res += a[i]
            a[i+1]-= a[i]
        else:
            res += a[i+1]
            res += (a[i]- a[i+1]) //2
            a[i+1]=0

    print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]
res = 0
for i in range(0,n-1):
    if a[i] == 0:
        continue
    elif a[i] <= a[i+1]:
        res += a[i]
        a[i+1]-= a[i]
    else:
        res += a[i+1]
        res += (a[i]- a[i+1]) //2
        a[i+1]=0

print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]
res = 0
for i in range(0,n):
    res += a[i] // 2
    a[i] = a[i] % 2
if n > 1:
    for i in range(0,n-1):
        if a[i] == 1 and a[i+1] == 1:
            res += 1
            a[i] -= 1
            a[i+1] -= 1

print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]
res = 0
for i in range(0,n):
    res += a[i] // 2
    a[i] = a[i] % 2

for i in range(0,n-1):
    if a[i] == 1 and a[i+1] == 1:
        res += 1
        a[i] -= 1
        a[i+1] -= 1

print(res)

Submission status: Wrong Answer

Solution code:
n=int(input())
A=[int(input()) for i in range(n)]

cnt=0
f=0
for i in range(n-1):
  if A[i]>0 and A[i+1]>0:
    tmp=min(A[i],A[i+1])
    cnt+=tmp
    A[i]=A[i]-tmp
    A[i+1]=A[i+1]-tmp
for i in range(n):
  cnt+=A[i]//2


print(cnt)

Submission status: Wrong Answer

Solution code:
n=int(input())
A=[int(input()) for i in range(n)]

cnt=0
f=0

for i in range(n):
  cnt+=A[i]//2
for i in range(n-1):
  if f==1:
    f=0
    continue
  else:
    if A[i]%2==A[i+1]%2==1:
      cnt+=1
      f=1
print(cnt)

Submission status: Wrong Answer

Solution code:
n=int(input())
cnt=0

A=[int(input()) for i in range(n)]

for i in range(n):
  cnt+=A[i]//2
for i in range(n-1):
  if A[i]%2==A[i+1]%2==1:
    cnt+=1
    i+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(input()) for _ in range(n)]
ans = 0
for i in range(1, n):
    b = min(a[i - 1:i + 1])
    ans += b
    a[i - 1] -= b
    a[i] -= b
for i in a:
    ans += i // 2
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(input()) for _ in range(n)]
ans = 0
for i, j in enumerate(a):
    ans += j // 2
    a[i]%=2
for i in range(1, n):
    b = min(a[i - 1:i + 1])
    ans += b
    a[i - 1] -= b
    a[i] -= b
print(ans)

Submission status: Wrong Answer

Solution code:
# 2019/09/18
# 問題文がクソ

import sys
input=sys.stdin.readline

n=int(input())
cnt=0

pre=0
for i in range(n):
    a=int(input())
    if a==0:
        pre=0
        continue
    if pre:
        cnt+=1            
        a-=1
    buf=a//2
    a-=buf
    cnt+=buf
    pre=a

print(cnt)

Submission status: Wrong Answer

Solution code:
# 2019/09/18

import sys
input=sys.stdin.readline

n=int(input())
a=[int(input()) for _ in range(n)]
cnt=0

for i in range(0,n-1,2):
    same=a[i]//2+a[i+1]//2
    diff=min(a[i],a[i+1])
    cnt+=(max(same,diff))        
    a[i],a[i+1]=0,0
print(cnt)

Submission status: Wrong Answer

Solution code:
# 2019/09/18

import sys
input=sys.stdin.readline

n=int(input())
cnt=0

rem=0
for i in range(n):
    a=int(input())
    if a==0:continue
    buf=a//2
    a-=buf
    cnt+=buf
    if rem:
        if a:
            cnt+=1            
        rem=0
print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [None]*N
answer = 0
for i in range(N):
    A[i] = int(input())
    answer += A[i] // 2
    A[i] = A[i] % 2

for i in range(N-1):
    if A[i] == 0:
        continue
    if A[i+1] == 1:
        answer += 1
        A[i] = 0
        A[i+1] = 0
print(answer)