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:
import sys
import heapq
from operator import itemgetter
from collections import deque, defaultdict
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def sol():
    N = int(input())
    cardCount = [int(input()) for _ in range(N)]

    ans = 0
    for i in range(N - 1):
        now = cardCount[i]
        ans += now // 2

        if now % 2 == 1:
            if cardCount[i + 1] > 0:
                ans += 1
                cardCount[i + 1] -= 1

    print(ans)


sol()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[0]+[int(input()) for _ in range(n)]

memo=[0]*(n+2)

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

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[int(input()) for i in range(n)]
ct=0
for i in range(n-1):
  x=min(l[i],l[i+1])
  ct+=x
  l[i]-=x
  l[i+1]-=x
for i in range(n):
  ct+=l[i]//2
  l[i]%=2
print(ct)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[int(input()) for i in range(n)]
ct=0
for i in range(n):
  ct+=l[i]//2
  l[i]%=2
for i in range(n-1):
  x=min(l[i],l[i+1])
  ct+=x
  l[i]-=x
  l[i+1]-=x
print(ct)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = 0
nums = [int(input()) for _ in range(N)]
for i in range(len(nums)):
    ans += nums[i]//2
    nums[i] %=  2

for i in range(len(nums)-1):
    if  nums[i] == 1 and nums[i + 1] == 1:
        ans += 1
        nums[i] -= 1
        nums[i + 1] -= 1
print(ans)

Submission status: Wrong Answer

Solution code:
# ひとつ前 自分 ひとつ後の順で優先な貪欲
# 0は0なので完全に無視

n = int(input())
arr = []
for _ in range(n):
  arr.append(int(input()))
arr.append(0)

count = 0
for i in range(1, n+1):
  if arr[i-1] > 1:
    if arr[i] == 0:
      count += arr[i-1]//2
    else:
      adapt = min(arr[i-1], arr[i])
      count += adapt
      arr[i-1] -= adapt
      arr[i] -= adapt
      count += arr[i-1]//2
      arr[i-1]%=2
  else:
     count += arr[i]//2
     arr[i]%=2

print(count)

Submission status: Wrong Answer

Solution code:
# ひとつ前 自分 ひとつ後の順で優先な貪欲
# 0は0なので完全に無視

n = int(input())
arr = []
for _ in range(n):
  arr.append(int(input()))

count = 0
for i in range(1, n):
  if arr[i-1] > 1:
    if arr[i] == 0:
      count += arr[i-1]//2
    else:
      adapt = min(arr[i-1], arr[i])
      count += adapt
      arr[i-1] -= adapt
      arr[i] -= adapt
      count += arr[i-1]//2
      arr[i-1]%=2
  else:
     count += arr[i]//2
     arr[i]%=2

print(count)

Submission status: Wrong Answer

Solution code:
# ひとつ前 自分 ひとつ後の順で優先な貪欲
# 0は0なので完全に無視

n = int(input())
arr = []
for _ in range(n):
  arr.append(int(input()))

count = 0
for i in range(1, n):
  if arr[i-1] > 1:
    if arr[i] == 0:
      count += arr[i-1]//2
    else:
      adapt = min(arr[i-1], arr[i])
      count += adapt
      arr[i-1] -= adapt
      arr[i] -= adapt
  else:
     count += arr[i]//2
     arr[i] = arr[i]%2

print(count)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[int(input()) for i in range(n)]
print(sum(l)//2)

Submission status: Wrong Answer

Solution code:
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:
    if i==n-1:break
    ans+=1
    l[i]=0;l[i+1]-=1
print(ans)

Submission status: Wrong Answer

Solution code:
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
for i in range(n-1):
  if l[i]==1 and l[i+1]==1:
    ans+=1
    l[i]=0;l[i+1]=0
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
*A, = [int(input()) for _ in [0]*N]

B = []
i = 0
for j,a in enumerate(A):
    if a == 0:
        B.append(A[i:j])
        i = j+1
else:
    B.append(A[i:])

def f(C):
    L = len(C)
    if L==0:return 0
    elif L==1:return C[0]//2
    ret = [0]*2
    for i in (0,1):
        c0 = i
        ret[i]+= (C[0]-c0)//2+c0
        for c in C[1:-1]:
            ret[i] += (c-c0)//2
            c0 = (c-c0)%2
            ret[i] += c0
        ret[i] += (C[-1]-c0)//2
    return min(ret)

ans = sum(map(f,B))
print(ans)

Submission status: Wrong Answer

Solution code:
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    N = int(input())
    A_ = [int(input()) for _ in range(N)]
    logging.info("Hello!")

    A_.append(0)
    counter = 0
    for i in range(0, N):
        if A_[i] == 0:
            continue
        else:
            if A_[i] > A_[i + 1]:
                counter += (A_[i + 1] + (A_[i] - A_[i + 1]) // 2)
                A_[i + 1] = 0
            else:
                counter += (A_[i])
                A_[i + 1] -= A_[i] 

    print(counter)
    
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())

ans = 0
a1 = 0
for _ in range(N):
    a = int(input())
    ans += a // 2
    if a % 2 == 1:
        a1 += 1
    elif a1 != 0:
        ans += a1 // 2
        a1 = 0
ans += a1 // 2

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

ans = 0
a1 = 0
for _ in range(N):
    a = int(input())
    ans += a // 2
    if a % 2 == 1:
        a1 += 1
    elif a1 != 0:
        ans += a1 // 2
        a1 = 0

print(ans)

Submission status: Wrong Answer

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

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

i = 0
while i < N - 1:
    if a[i] > 0 and a[i+1] >0:
        ans += 1
        a[i] = 0
        a[i+1]  = 0
    i += 1

print(ans)

Submission status: Wrong Answer

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

ans = 0
for i in range(N):
    if a[i] == 0:
        continue
    elif a[i] == 1:
        pass
    else:
        ans += a[i]//2
        a[i] = a[i]%2

i = 0
while i < N - 1:
    if a[i] == 1 and a[i+1] == 1:
        ans += 1
        i +=1
    i += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
ans=0
A=[]
for _ in range(N):
    ipt=int(input())
    ans+=(ipt//2)
    A.append(ipt%2)

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

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
ans=0
A=[]
for _ in range(N):
    ipt=int(input())
    ans+=ipt//2
    A.append(ipt%2)

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

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]
ans = A[0] // 2
A[0] = A[0] % 2
for i in range(1, N):
    if A[i-1] + A[i] >= 2:
        ans += 1; A[i] -= 1
    q, r = divmod(A[i], 2); A[i] = r
    ans += q
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()

ans = 0
plus = 0
a = [ni() for _ in range(n)]

for ai in a:
    ans += ((ai+plus) // 2)
    plus = ai % 2 if ai > 0 else 0

print(ans)

Submission status: Wrong Answer

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

ans = 0
cnt = 0

for a in A :
    ans += (a+cnt) // 2
    cnt = (a+cnt) % 2

print(ans)

Submission status: Wrong Answer

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

ans = 0
cnt = 0

for a in A :
    ans += (a+cnt) // 2
    cnt = a % 2

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    ans = 0
    prev = 0
    for a in A:
        ans += a // 2
        if prev + (a%2) == 2:
            ans += 1
        prev = a % 2
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

for i in A:
    if i != 0:
        tmp += i
    else:
        ans += tmp//2
        tmp = 0

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])
    ans += tmp
    A[i] -= tmp
    A[i+1] -= tmp

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

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):
    ans += A[i] // 2
    if A[i] % 2 == 0:
        A[i] = 0
    else:
        A[i] = 1

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:
a = int(input())
count = 0
mod = 0
for i in range(a):
    b = int(input())
    if b == 0:
        mod = 0
    c = b + mod
    if not c==0:
        count += b//2
        mod = b%2
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = 0
flag = False
for i in range(N):
    a = int(input())
    if flag and a>0:
        a -= 1
        ans += 1
    ans += a//2
    if a % 2 == 0:
        flag = False

print(ans)

Submission status: Wrong Answer

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

ans = 0

flag = True
for i in range(N):
    if flag and A[i] % 2 == 0:
        ans += A[i] // 2
    elif flag and A[i] % 2 == 1:
        ans += A[i] // 2
        flag = False
    elif A[i] % 2 == 0:
        ans += A[i] // 2
        flag = True
    else:
        ans += (A[i]+1)//2
        flag = True
Ans = ans
ans = 0
A.reverse()
flag = True
for i in range(N):
    if flag and A[i] % 2 == 0:
        ans += A[i] // 2
        flag = True
    elif flag and A[i] % 2 == 1:
        ans += A[i] // 2
        flag = False
    elif A[i] % 2 == 0:
        ans += A[i] // 2
        flag = True
    else:
        ans += (A[i]+1)//2
        flag = True
print(max(ans,Ans))

Submission status: Wrong Answer

Solution code:
n=int(input())
arr=[int(input()) for _ in range(n)]
ans=0
for i in range(n-1):
  tmp1=min(arr[i],arr[i+1])
  tmp2=arr[i]//2+arr[i+1]//2
  if tmp2>=tmp1:
    ans+=arr[i]//2
  else:
    ans+=tmp1
    arr[i+1]=0
ans+=arr[n-1]//2
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
arr=[int(input()) for _ in range(n)]
ans=0
for i in range(n-1):
  if arr[i]==0:
    continue
  tmp1=min(arr[i],arr[i+1])
  tmp2=arr[i]//2+arr[i+1]//2
  ans+=max(tmp1,tmp2)
  arr[i+1]=0
ans+=arr[n-1]//2
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(input()) for _ in range(n)]
ans = 0

for i in range(n-1):
    ans += a[i]//2
    if a[i]%2 == 1 and a[i+1] == 1:
        a[i+1] -= 1
        ans += 1
print(ans+a[n-1]//2)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(input()) for _ in range(n)]
ans = 0

for i in range(n-1):
    ans += a[i]//2
    if a[i]%2 == 1 and a[i+1] == 1:
        a[i+1] -= 1
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = 0
a = []
for _ in range(n):
    ai = int(input())
    ans += ai//2
    a.append(ai%2)

for i in range(n-1):
    if a[i] == 1 and a[i+1] == 1:
        a[i+1] -= 1
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = 0
a = []
for _ in range(n):
    ai = int(input())
    ans += ai//2
    a.append(ai%2)

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

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = 0
a = []
for _ in range(n):
    ai = int(input())
    ans += ai//2
    a.append(ai%2)

pre = a[0]
for i in range(1, n):
    if pre*a[i] == 0:
        pre = a[i]
    else:
        ans += 1
        pre = 0
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
N = int(input())
L = [int(input()) for _ in range(N)]
ans = 0
prev = 0
for a in L:
    a += prev
    ans += a//2
    prev = a % 2
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
N = int(input())
L = [int(input()) for _ in range(N)]
ans = 0
prev = 0
for a in L:
    ans += a//2
    if a % 2 == 1:
        if prev == 1:
            ans += 1
            prev = 0
        else:
            prev = 1
    else:
        prev = 0
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=0
res=0
for i in range(n):
  a=int(input())
  if res==1:
    a+=1
  ans+=a//2
  if a%2==1:
    res=1
  else:
    res=0
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=0
res=0
for i in range(n):
  a=int(input())
  if res==1:
    a+=1
    res=0
  ans+=a//2
  if a%2==1:
    res=1
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=0
res=0
for i in range(n):
  a=int(input())
  ans+=a//2
  if a%2==1:
    if res==1:
      ans+=1
      res=0
    else:
      res=1
  else:
    res=0
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=0
res=0
for i in range(n):
  a=int(input())
  ans+=a//2
  if a%2==1:
    if res==1:
      ans+=0
      res=0
    else:
      res=1
  else:
    res=0
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=0
res=0
for i in range(n):
  a=int(input())
  ans+=a//2
  if a%2==1:
    if res==1:
      ans+=0
      res=0
    else:
      res=1
  res=0
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())

c=0
l=[]

for i in range(n):
  x=int(input())
  c+=x//2
  l.append(x%2)

c1=c
l2=l[:]

for i in range(len(l)-1):
  if l[i]==1 and l[i+1]==1:
    c1+=1
    l[i]=0
    l[i+1]=0

c2=c
l2.reverse()
for i in range(len(l2)-1):
  if l2[i]==1 and l2[i+1]==1:
    c2+=1
    l2[i]=0
    l2[i+1]=0

print(max(c1,c2))

Submission status: Wrong Answer

Solution code:
n=int(input())

c=0
l=[]

for i in range(n):
  x=int(input())
  c+=x//2
  l.append(x%2)

for i in range(len(l)-1):
  if l[i]==1 and l[i+1]==1:
    c+=1
    l[i]=0
    l[i+1]=0

print(c)

Submission status: Wrong Answer

Solution code:
N = int(input())
score = 0
A = []
for i in range(N):
    num = int(input())
    if num == 0:
        A.append(0)
    if num == 1 or num == 2:
        A.append(num)
    if num == 3:
        score += 1
        A.append(1)
    if num >= 4:
        score += (num-2) // 2
        A.append(2 - num % 2)

A.append(0)

length = 0
for i in range(N):
    if A[i] == 1 and A[i+1] == 1:
        score += 1
        A[i+1] = 0
        length = 0
    if A[i] == 1 and A[i+1] == 2:
        length += 1
    if A[i] == 2 and A[i+1] == 0:
        if length >= 1:
            score += length
            length = 0
        else:
            score += 1
    if A[i] == 2 and A[i+1] == 1:
        if length >= 1:
            score += length + 1
            A[i+1] = 0
            length = 0
        else:
            score += 1
    if A[i] == 2 and A[i+1] == 2:
        if length >= 1:
            length += 1
        else:
            score += 2
            A[i+1] = 0



print(score)

Submission status: Wrong Answer

Solution code:
N = int(input())
score = 0
A = []
for i in range(N):
    num = int(input())
    if num == 0:
        A.append(0)
    if num == 1 or num == 2:
        A.append(num)
    if num == 3:
        score += 1
        A.append(1)
    if num >= 4:
        score += (num-2) // 2
        A.append(2 - num % 2)

A.append(0)

length = 0
for i in range(N):
    if A[i] == 1 and A[i+1] == 1:
        score += 1
        A[i+1] = 0
        length = 0
    if A[i] == 1 and A[i+1] == 2:
        length += 1
    if A[i] == 2 and A[i+1] == 0:
        if length >= 1:
            score += length
            length = 0
        else:
            score += 1
    if A[i] == 2 and A[i+1] == 1:
        if length >= 1:
            score += length + 1
            A[i+1] = 0
            length = 0
        else:
            score += 1
            A[i+1] = 0
    if A[i] == 2 and A[i+1] == 2:
        if length >= 1:
            length += 1
        else:
            score += 2
            A[i+1] = 0



print(score)

Submission status: Wrong Answer

Solution code:
N = int(input())
score = 0
A = []
for i in range(N):
    num = int(input())
    if num == 0:
        A.append(0)
    if num == 1 or num == 2:
        A.append(num)
    if num == 3:
        score += 1
        A.append(1)
    if num >= 4:
        score += (num-2) // 2
        A.append(2 - num % 2)

A.append(0)

length = 0
for i in range(N):
    if A[i] == 1 and A[i+1] == 1:
        score += 1
        A[i+1] = 0
        length = 0
    if A[i] == 1 and A[i+1] == 2:
        length += 1
    if A[i] == 2 and A[i+1] == 0:
        if length >= 1:
            score += length
            length = 0
        else:
            score += 1
            length = 0
    if A[i] == 2 and A[i+1] == 1:
        if length >= 1:
            score += length + 1
            length = 0
        else:
            score += 1
            length = 0
    if A[i] == 2 and A[i+1] == 2:
        if length >= 1:
            length += 1
        else:
            score += 2
            length = 0
            A[i+1] = 0



print(score)

Submission status: Wrong Answer

Solution code:
N = int(input())
score = 0
A = []
for i in range(N):
    num = int(input())
    score += num // 2
    A.append(num % 2)

length = 0
for i in range(N):
    if A[i] == 1:
        length += 1
    else:
        score += length // 2
        length = 0

score += length // 2

print(score)

Submission status: Wrong Answer

Solution code:
N = int(input())
score = 0
A = []
for i in range(N):
    num = int(input())
    score += num // 2
    A.append(num % 2)

length = 0
for i in range(N):
    if A[i] == 1:
        length += 1
    else:
        score += length // 2
        length = 0

print(score)

Submission status: Wrong Answer

Solution code:
n,*a=map(int,open(0).read().split())
b=[i%2 for i in a]
#print(b)
for x in range(n-1):
    if b[x+1] and b[x]:
        b[x+1]=0
        b[x]=0
#print(b)
print((sum(a)-sum(b))//2)

Submission status: Wrong Answer

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

res=0
cnt=0
for i in range(N):
    if A[i]==0:
        res+=cnt
        cnt=0
    else:
        cnt=(cnt+1)%2
res+=cnt
print((sum(A)-res)//2)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[int(input()) for _ in range(N)]
 
ans=0
idx=[0]
#0,1,2のみにする
for i in range(N):
  if A[i]==0:
    idx.append(i+1)
  continue
  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
n=0
for iidx in idx[1:]:
  ans+=sum(A[n:iidx])//2
  n=iidx
print(ans)
exit(0)
  
for i in range(1,N-1):
  b,a,c=A[i-1:i+2]
  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)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[int(input()) for _ in range(N)]
 
ans=0
idx=[0]
#0,1,2のみにする
for i in range(N):
  if A[i]==0:
    idx.append(i)
  continue
  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
n=0
for iidx in idx[1:]:
  ans+=sum(A[n:iidx])//2
  n=iidx+1
print(ans)
exit(0)
  
for i in range(1,N-1):
  b,a,c=A[i-1:i+2]
  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)

Submission status: Wrong Answer

Solution code:
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+2]
  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)

Submission status: Wrong Answer

Solution code:
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):
  a,b=A[i-1:i+1]
  if a%2==1 and b%2==1:
    ans+=1
    A[i-1]-=1
    A[i]-=1  
  
for i in range(N):
  a=A[i]
  if a==2:
    if 0<=i-1 and A[i-1]%2==1:
      ans+=1
      A[i-1]-=1
      A[i]-=1
    if i+1<N and A[i+1]%2==1: 
      ans+=1
      A[i]-=1
      A[i+1]-=1    
    
ans+=len(list(filter(lambda x:x==2,A)))
print(ans)

Submission status: Wrong Answer

Solution code:
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):
  a,b=A[i-1:i+1]
  if a%2==1 and b%2==1:
    ans+=1
    A[i-1]-=1
    A[i]-=1  
  
for i in range(1,N-1):
  b,a,c=A[i-1:i+2]
  if a==2:
    t=(b%2==1)+(c%2==1)
    A[i]-=t
    A[i-1]-=b%2
    A[i+1]-=c%2
    ans+=t

    
ans+=len(list(filter(lambda x:x==2,A)))
print(ans)

Submission status: Wrong Answer

Solution code:
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+2]
  if a==2:
    t=(b%2==1)+(c%2==1)
    A[i]-=t
    A[i-1]-=b%2
    A[i+1]-=c%2
    ans+=t

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)

Submission status: Wrong Answer

Solution code:
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+2]
  if a==2:
    t=(b%2==1)+(c%2==1)
    A[i]-=t
    A[i-1]-=b%2
    A[i+1]-=c%2
    ans+=t
ans+=len(list(filter(lambda x:x==2,A)))
print(ans)

Submission status: Wrong Answer

Solution code:
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+2]
  if a==2:
    t=(b%2==1)+(c%2==1)
    A[i]-=t
    ans+=t
ans+=len(list(filter(lambda x:x==2,A)))
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[int(input()) for _ in range(N)]
 
ans=0
for i in range(0,N-1):
  a,b=A[i],A[i+1] 
  if  a%2==1 and a<b: 
    ans+=a%2
    A[i]-=1
    A[i+1]-=1

A=list(reversed(A))
for  i in range(N-1):
  a,b=A[i:i+2]
  if a<b and a%2==1:
    ans+=a%2
    A[i]-=a%2
    A[i+1]-=a%2

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 in range(0,N-1,2):
  a,b=A[i],A[i+1] 
  if b%2==1 and a%2==1: 
    ans+=a%2
    A[i]-=1
    A[i+1]-=1

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 in range(N-1):
  a,b=A[i],A[i+1] 
  if a<=b and a%2==1: 
    ans+=a%2
    A[i]-=a%2
    A[i+1]-=a%2
A=list(reversed(A))
for i in range(N-1 ):
  a,b=A[i:i+2]
  if a<=b and a%2==1:
    ans+=a%2
    A[i]-=a%2
    A[i+1]-=a%2

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 in range(N-1):
  a,b=A[i],A[i+1] 
  if a<=b: 
    ans+=a
    A[i]=0
    A[i+1]-=a
A=list(reversed(A))
for i in range(N-1 ):
  a,b=A[i:i+2]
  if a<=b:
    ans+=a
    A[i]=0
    A[i+1]-=a

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 in range(N-1):
  a,b=A[i],A[i+1] 
  #print("ans: ",ans)
  #print("i:",i ,a,b ) 
  if a%2==0 or b%2==0: continue
  if a<b: 
    ans+=a
    A[i]=0
    A[i+1]-=a
  else:
    ans+=b
    A[i]-=b
    A[i+1]-=b
    #ans+=(a-b)//2
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 in range(N-1):
  a,b=A[i],A[i+1] 
  #print("ans: ",ans)
  #print("i:",i ,a,b ) 
  if a%2==0: continue
  if a<b: 
    ans+=a
    A[i]=0
    A[i+1]-=a
  else:
    ans+=b
    A[i]-=b
    A[i+1]-=b
    #ans+=(a-b)//2
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 in range(N-1):
  a,b=A[i],A[i+1]
  if a<b: 
    ans+=a
    A[i+1]-=a
  else:
    ans+=b
    A[i+1]-=b
    ans+=(a-b)//2
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[int(input()) for _ in range(N)]
 
ans=0
for i in range(1,N):
  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)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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


ans = 0
tmp = 0
for a in A:
    if a == 0:
        ans += tmp//2
        tmp = 0
    else:
        tmp += a
print(ans)

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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


def cnt(l):
    ret = 0
    r = 0
    for a in l:
        if a == 0:
            r = 0
            continue

        else:
            if r == 0:
                tmp = a
            else:
                ret += 1
                tmp = a-1
            ret += tmp//2
            r = a % 2
    return ret


print(cnt(A))

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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


ans = 0
r = 0
for a in A:
    tmp = a+r
    ans += tmp//2
    r = tmp % 2
print(ans)

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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


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

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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


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

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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


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

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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


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

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())

ans = 0
for _ in range(N):
    a = int(input())
    ans += a//2
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
L = []
ans = 0
for i in range(N) :
    a = int(input())
    ans += a//2
    L.append(a%2)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0

for i in range(N) :
    ans += A[i]//2
    A[i] %= 2
    if i >= 1 :
        if A[i-1] == A[i] == 1 :
            ans += 1
            A[i] = 0
print(ans)