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:
s=t=0
for _ in[0]*int(input()):a=int(input());s+=(a+t*(a>0))//2;t=a%2
print(s+t//2)

Submission status: Wrong Answer

Solution code:
s=t=0
for _ in[0]*int(input()):a=int(input());s+=(a+t*(a>0))//2;t=a%2
print(s)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []
tmp = []
for i in range(N):
    a = int(input())
    if a != 0:
        tmp.append(a)
    else:
        A.append(tmp)
        tmp = []
A.append(tmp)

num = 0
for i in range(len(A)):
    for j in range(len(A[i])):
        num += A[i][j] // 2
        if A[i][j] % 2 != 0 and j < len(A[i]) - 1:
            A[i][j] += 1


print(num)

Submission status: Wrong Answer

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

num = 0
pre = 0
for i in range(N):
    num += A[i] // 2
    if A[i] % 2 != 0:
        if pre == 1:
            num += 1
            pre = 0
        else:
            pre = 1
    else:
        pre = 0

print(num)

Submission status: Wrong Answer

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

items = {}
for i, a in enumerate(a_list):
    items[i + 1] = a

sorted_items = sorted(items.items(), key=lambda x: -x[0])

ans = 0
for k, _ in sorted_items:
    v = items[k]
    if k - 1 in items:
        tmp = items[k - 1]
        if tmp >= v:
            ans += v
            items[k-1] -= v
        else:
            ans += tmp
            items[k-1] -= tmp
            v -= tmp
            ans += v // 2
    else:
        ans += v // 2
print(ans)

Submission status: Wrong Answer

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

items = {}
for i, a in enumerate(a_list):
    items[i + 1] = a

sorted_items = sorted(items.items(), key=lambda x: -x[0])

ans = 0
for k, _ in sorted_items:
    v = items[k]
    if k - 1 in items:
        tmp = items[k - 1]
        if tmp >= v:
            ans += v
            items[k-1] -= v
        else:
            ans += tmp
            v -= tmp
            ans += v // 2
    else:
        ans += v // 2
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = int(input())
count = 0
r = 0
for i in range(a):
    l = int(input()) 
    lr = l + r
    count += lr // 2
    if l % 2 == 1:
        r = 1
    else:
        r = 0
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
moto =[]
a = []
for _ in range(n):
  b = int(input())
  moto.append(b)
  if b%2 == 1:
    a.append(1)
  elif b:
    a.append(2)
  else:
    a.append(0)
for i in range(n-1):
  if a[i]%2 == 1:
    if a[i+1]%2 == 1:
      a[i+1] += 1
      a[i+1] %=2
for i in range(n):
  a[i] %=2
print((sum(moto)-sum(a))//2)

Submission status: Wrong Answer

Solution code:
n = int(input())
moto =[]
a = []
for _ in range(n):
  b = int(input())
  moto.append(b)
  if b%2 == 1:
    a.append(1)
  elif b:
    a.append(2)
  else:
    a.append(0)
for i in range(n-1):
  if a[i]:
    if a[i+1]:
      a[i+1] += 1
      a[i+1] %=2
for i in range(n):
  a[i] %=2
print((sum(moto)-sum(a))//2)

Submission status: Wrong Answer

Solution code:
n = int(input())
moto =[]
a = []
for _ in range(n):
  b = int(input())
  moto.append(b)
  if b%2 == 1:
    a.append(1)
  elif b:
    a.append(2)
  else:
    a.append(0)
for i in range(n-1):
  if a[i]%2 == 1:
    a[i+1] += 1
    a[i+1] %=2
  a[i] = 0
print((sum(moto)-sum(a))//2)

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] == 0:
        continue
    b = a[i] // 2
    if a[i] % 2 == 0:
        ret += b - 1
        a[i] = 2
    else:
        ret += b
        a[i] = 1

for i in range(n-1):
    if a[i] == 1 and a[i+1] > 0:
        ret +=1
        a[i+1] -= 1
    if a[i] == 2:
        ret += 1

print(ret)

Submission status: Wrong Answer

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

i = 0
for i in range(N-1):
    if OE[i] == 1 and OE[i+1] == 1:
        Ans += 1
        OE[i], OE[i+1] == 0, 0

print(Ans)

Submission status: Wrong Answer

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

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

print(Ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = ''
for _ in range(N):
    A += input()

ans = [sum(map(int, str(x)))//2 for x in A.split('0')]
print(sum(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = ''
for _ in range(N):
    A += input()

ans = [sum(map(int, str(x)))//2 for x in A]
print(sum(ans))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
cnt = 0
a = 0
for _ in range(n):
    x = int(input())
    cnt += (a+x)//2
    a = (a+x)%2
print(cnt)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
cnt = 0
a = 0
for _ in range(n):
    x = int(input())
    cnt += (a+x)//2
    a = x%2
print(cnt)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
aa1 = []
aa2 = []
for _ in range(n):
    x = int(input())
    aa1.append(x)
    aa2.append(x)
aa2.reverse()


a1 = aa1[0]
cnt1 = 0
for i in range(1,n):
    a2 = aa1[i]
    if a1<=a2:
        cnt1 += a1
        a1 = a2-a1
    else:
        cnt1 += a2+(a1-a2)//2
        a1 = 0
cnt1 += a1//2

a1 = aa2[0]
cnt2 = 0
for i in range(1,n):
    a2 = aa2[i]
    if a1<=a2:
        cnt2 += a1
        a1 = a2-a1
    else:
        cnt2 += a2+(a1-a2)//2
        a1 = 0
cnt2 += a1//2

print(max(cnt1,cnt2))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
a1 = int(input())
cnt = 0

for _ in range(n-1):
    a2 = int(input())
    if a1<=a2:
        cnt += a1
        a1 = a2-a1
    else:
        cnt += a2+(a1-a2)//2
        a1 = 0
cnt += a1//2
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[]
res=0
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)

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] % 2 == 0:
        ans += a[i] // 2
    elif i != n - 1:
        if a[i + 1] > 0:
            a[i + 1] -= 1
            a[i] += 1
        ans += (a[i]) // 2
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
lis = [int(input()) for i in range(n)]
cou = 0
num = 0
for i in range(n):
  if lis[i] == 0:
    cou += (num // 2)
    num = 0
  else:
    num += lis[i]
print(cou)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

ans = 0
prev = 0

for i in range(N):
  a = int(input())
  ans += a // 2
  if prev == 1 and a%2 == 1:
    ans += 1
    prev = 0
  else:
    prev = a%2
    
print(ans)

Submission status: Wrong Answer

Solution code:
t=c=0
for _ in[0]*input():i=input();c+=(i+t)/2;t=i%2&(i>0)
print c

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(input()) for i in range(N)]
cnt=0
for i in range(N):
    if a[i]//2 >=1:
        cnt+=a[i]//2
        a[i]-=a[i]//2*2
    if a[i-1]==1 and a[i]==1 and i!=0:
        cnt+=1
        a[i-1]-=1
        a[i]-=1
print(cnt)

Submission status: Wrong Answer

Solution code:
# coding:utf-8

INF = float('inf')


def inpl(): return list(map(int, input().split()))


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

ans = 0
prev = 0
for i in range(N):
    q, mod = divmod(A[i], 2)
    ans += q
    prev += mod
    if prev == 2:
        ans += 1
        prev = 0
    else:
        prev = mod

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[int(input()) for _ in range(n)]
v=sum(map(lambda x:x//2,l))
print(v)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[int(input()) for _ in range(n)]
v=sum(map(lambda x:x//2,l))
*a,=map(lambda x:x%2,l)
for i in range(len(a)-1):
  if a[i] and a[i+1]:
    b=min(l[i],l[i+1])
    l[i]-=b
    l[i+1]-=b
    v+=b
print(v)

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]=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())

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

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

a = 0
i = 0
while i+1 < n :
	if arr[i] == arr[i+1] == 1:
		a += 1
	
	i += 2

b = 0
i = 1
while i+1 < n:
	if arr[i] == arr[i+1] == 1:
		b += 1
	i += 2

print count + max(a,b)

Submission status: Wrong Answer

Solution code:
N=int(input())
p=0
q=0
for i in range(N):
    s=int(input())
    if s%2==0:
        p+=s//2
        q=0
    elif s%2==1:
        if q==0:
            p+=s//2
            q=1
        elif q==1:
            p+=(s+q)//2
            q=0
print(p)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
def inpl(): return map(int, input().split())
N = int(input())

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

#print(A)

for i in range(N):
    d, m = divmod(A[i], 2)
    ans += d
    A[i] = m

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
def inpl(): return map(int, input().split())
N = int(input())

A = []
ans = 0
for _ in range(N):
    d, m = divmod(int(input()), 2)
    ans += d
    A.append(m)

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

Submission status: Wrong Answer

Solution code:
n = int(input())
nums = []
for i in range(n):
  nums.append(int(input()))
count = 0
for j in range(n):
  if nums[j]%2 == 0:
    count += (nums[j]//2)
  elif j < (n-1):
    if 1 <= nums[j+1]:
      nums[j+1] -= 1
      count += (nums[j]//2) + 1
    else:
      count += (nums[j]//2)
print(count)

Submission status: Wrong Answer

Solution code:
from collections import OrderedDict, deque
N = int(input())
A = OrderedDict({i: int(input()) for i in range(1, N+1)})
ans = 0

for key in range(1, N+1):
    ans += A[key] // 2
    A[key] %= 2

rest = [key for key, value in A.items() if value == 1]

rest_forward = deque(rest.copy())
while len(rest_forward) > 1:
    a1 = rest_forward.popleft()
    if abs(a1 - rest_forward[0]) <= 1:
        ans += 1
        rest_forward.popleft()


print(ans)

Submission status: Wrong Answer

Solution code:
from collections import OrderedDict, deque
N = int(input())
A = OrderedDict({i: int(input()) for i in range(1, N+1)})
ans = 0

for key in range(1, N+1):
    ans += A[key] // 2
    A[key] %= 2

rest = [key for key, value in A.items() if value == 1]

rest_forward = deque(rest.copy())
forward_add = 0
while len(rest_forward) > 1:
    a1 = rest_forward.popleft()
    if abs(a1 - rest_forward[0]) <= 1:
        forward_add += 1
        rest_forward.popleft()

rest_backward = deque(rest.copy())
backward_add = 0
while len(rest_backward) > 1:
    a1 = rest_backward.pop()
    if abs(a1 - rest_backward[-1]) <= 1:
        backward_add += 1
        rest_backward.pop()

print(ans + max(forward_add, backward_add))

Submission status: Wrong Answer

Solution code:


n = input()
ans = 0
last = 0
for i in range(n):
    a = input()
    ans += a / 2
    if a % 2 == 1 and last:
        last = 0
        ans += 1
    else:
        last = a % 2
print ans

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
src = [int(input()) for i in range(N)]
ans = rem = 0
for a in src:
    ans += a//2
    if a%2:
        if rem:
            ans += 1
            rem = 0
        else:
            rem = 1
    else:
        rem = 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):
  curr = min(A[i],A[i+1])
  A[i+1] -= curr
  curr += (A[i]-curr)//2
  ans+= curr
ans+=A[N-1]//2
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 10


def main():
    N = int(input())
    A_list = [int(input()) for i in range(N)]
    ans = 0
    pre_rest = 0
    for a in A_list:
        ans += a // 2
        rest = a % 2
        if pre_rest and rest:
            ans += 1
            pre_rest = 0
        else:
            pre_rest = a % 2

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from random import *

def readline():
    return list(map(int,input().split(' ')))

n = readline()[0]
prev = 0
ans = 0
for i in range(0,n):
    x = readline()[0]
    s = min(prev,x)
    prev = prev -s
    x = x - s
    ans = ans + s
    ans = ans + (prev >> 1)
    prev = x

print(ans)

Submission status: Wrong Answer

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

ans = 0
for idx,a in enumerate(As):
    if idx!=len(As)-1:
        tmp = min(As[idx], As[idx+1])
        # print('\t', tmp)
        ans += tmp
        As[idx] -= tmp
        As[idx+1] -= tmp

        tmp = As[idx]
        ans += tmp//2
        As[idx] = 1 * As[idx]%2
    else:
        tmp = As[idx]
        ans += tmp//2
        As[idx] = 1 * As[idx]%2
    # print(ans,As)

As = list(reversed(As))
for idx,a in enumerate(As):
    if idx!=len(As)-1:
        tmp = min(As[idx], As[idx+1])
        # print('\t', tmp)
        ans += tmp
        As[idx] -= tmp
        As[idx+1] -= tmp

        tmp = As[idx]
        ans += tmp//2
        As[idx] = 1 * As[idx]%2
    else:
        tmp = As[idx]
        ans += tmp//2
        As[idx] = 1 * As[idx]%2
    # print(ans,As)
# print('hhh')
print(ans)

Submission status: Wrong Answer

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

ans = 0
for idx,a in enumerate(As):
    if idx!=len(As)-1:
        tmp = min(a, As[idx+1])
        # print('\t', tmp)
        ans += tmp
        As[idx] -= tmp
        As[idx+1] -= tmp

        tmp = As[idx]
        ans += tmp//2
        As[idx] = 1 * As[idx]%2
    else:
        tmp = As[idx]
        ans += tmp//2
        As[idx] = 1 * As[idx]%2
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#AGC003B

n=int(raw_input())
s=[int(raw_input()) for i in xrange(n)]
cnt=0
i=0
while i<n:
 cnt+=s[i]/2
 if s[i]%2==1:
  if i<n-2:
   s[i+1]+=1
 i+=1
print cnt

Submission status: Wrong Answer

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

cnt = 0
i = 0
while i < n:
    if a[i] >= 2:
        pairs = a[i] // 2
        cnt += pairs
        a[i] -= (pairs * 2)

    elif a[i] == 1:
        if i + 1 >= n - 1:
            break

        if a[i + 1] > 0:
            cnt += 1
            a[i] -= 1
            a[i + 1] -= 1

        else:
            i += 1

    else:
        i += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
aArray = []
for i in range(N):
    aArray.append(int(raw_input()))

countPair = 0
for i in range(N):
    countPair += aArray[i] / 2
    if (i != (N - 1)):
        if (aArray[i]  % 2 == 1) and (aArray[i + 1] % 2 == 1):
            countPair += 1
            aArray[i + 1] -= 1
            print countPair

print countPair

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import itertools
if __name__ == '__main__':
    n = int(input())
    a = [0]
    cards = []
    for i in range(n):
        a.append(int(input()))
    for i in range(1, n + 1):
        for j in range(a[i]):
            cards.append(i)
    l = list(itertools.combinations(cards, 2));
    fl = list(filter(lambda p:abs(p[0] - p[1]) <= 1, l))
    count = [0]*(n+1)
    ans = []
    for f in fl:
        print(f[0], f[1])
        count[f[0]] += 1
        count[f[1]] += 1
        if (count[f[0]] > a[f[0]]):
            count[f[0]] -= 1
            count[f[1]] -= 1
            continue
        if (count[f[1]] > a[f[1]]):
            count[f[0]] -= 1
            count[f[1]] -= 1
            continue
        ans.append(f)
    print(len(ans))

Submission status: Wrong Answer

Solution code:
import sys

#sys.stdin = open('b_2.txt', 'r')
N = int(raw_input())
nums = []

for x in range(N):
	nums.append((x+1, int(raw_input())))

count = 0
for x in range(N):
	count = count + nums[x][1] / 2
	nums[x] = (x+1, nums[x][1] % 2)
	if ((x > 0) and (nums[x - 1][1] > 0) and (nums[x][1] > 0)):
		count = count + 1
		nums[x] = (x+1, 0)
print str(count)

Submission status: Wrong Answer

Solution code:
import sys

#sys.stdin = open('b_2.txt', 'r')
N = int(raw_input())
nums = []

for x in range(N):
	nums.append((x+1, int(raw_input())))

count = 0
for x in range(N):
	count = count + nums[x][1] / 2
	print '(x , count): ' + str((x + 1, count))
	nums[x] = (x+1, nums[x][1] % 2)
	if ((x > 0) and (nums[x - 1][1] > 0) and (nums[x][1] > 0)):
		count = count + 1
print str(count)

Submission status: Wrong Answer

Solution code:
import copy
N = int(input())
A = [int(input()) for k in range(N)]
B = copy.deepcopy(A)
B.reverse()

ans = 0
for k in range(N-1):
    temp = min(A[k],A[k+1])
    ans += temp
    A[k] -= temp
    A[k+1] -= temp
for k in range(N):
    ans += A[k]//2

ans2 = 0
for k in range(N-1):
    temp = min(B[k],B[k+1])
    ans2 += temp
    B[k] -= temp
    B[k+1] -= temp
for k in range(N):
    ans2 += B[k]//2

print(max(ans,ans2))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []
for i in range(N):
	A.append(int(input()))
if N % 2:
	B = [x for x in A if A.index(x) % 2 == 0]
	m = min(B)
	i = B.index(m) * 2
	a = 0
	for j in range(0,i,2):
		a += int((A[j] + A[j+1]) / 2)
	for k in range(i+1,N,2):
		a += int((A[j] + A[j+1]) / 2)
else:
	a = 0
	for i in range(0,N,2):
		a += int((A[i] + A[i+1]) / 2)
print(a)

Submission status: Wrong Answer

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

ans = 0
for k in range(N-1):
    temp = min(A[k],A[k+1])
    ans += temp
    A[k] -= temp
    A[k+1] -= temp
 
for k in range(N):
    ans += A[k]//2

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []
for i in range(N):
	A.append(int(input()))
if N % 2:
	B = [x for x in A if A.index(x) % 2 == 0]
	m = min(B)
	i = B.index(m) * 2
	a = 0
	for j in range((i+1)%2,i,2):
		a += int((A[i] + A[i+1]) / 2)
	for k in range(i+1,N,2):
		a += int((A[i] + A[i+1]) / 2)
else:
	a = 0
	for i in range(0,N,2):
		a += int((A[i] + A[i+1]) / 2)
print(a)

Submission status: Wrong Answer

Solution code:
N = int(input())
xs = list(map(int, (input() for _ in range(N))))
i = 0
s = 0
while i < len(xs):
    if not i+1 < len(xs):
        s += xs[i] // 2
    elif xs[i] == xs[i+1]:
        s += xs[i]
        i += 1
    else:
        s += xs[i] // 2
    i += 1

print(s)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []
for i in range(N):
	A.append(int(input()))
if N % 2:
	b = 0
	for i in range(N):
		a = 0
		for j in range(0,i,2):
			a += int((A[i] + A[i+1]) / 2)
		for k in range(i+1,N,2):
			a += int((A[i] + A[i+1]) / 2)
		b = max(b,a)
	print(b)
else:
	a = 0
	for i in range(0,N,2):
		a += int((A[i] + A[i+1]) / 2)
	print(a)

Submission status: Wrong Answer

Solution code:
n = input()
a = []
for i in range(n):
    s = input()
    a.append(s)

pair = 0

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

for i in range(0,n-1):
    p = min(a[i],a[i+1])
    pair += p
    a[i] -= p
    a[i+1] -= p




print pair

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
# A = [0] * 1000000010
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

Submission status: Wrong Answer

Solution code:
# coding: UTF-8
n = int(raw_input())
a =[]
for var in range(n):
    a.append(int(raw_input()))
pair = 0
flag = True

for now in range(len(a) -2):
    if a[now] % 2 == 1 and a[now+1] % 2 == 0 and a[now+2] % 2 == 1:
        pair = pair + (a[now]+a[now+1]+a[now+2])/2
        a[now] = 0
        a[now+1] = 0
        a[now+2] = 0

for now in range(len(a)):

    if a[now] % 2 == 0:
        pair = pair + a[now]/2
        a[now] = 0
    elif a[now] % 2 == 1:
        pair = pair + a[now]/2
        a[now] = 1
        if now == 0 or now == len(a)-1:
            pass
        else:
            if a[now+1]  != 0:
                pair = pair + 1
                a[now+1] = a[now+1]-1
print pair

Submission status: Wrong Answer

Solution code:
import sys
n = int(sys.stdin.readline().strip())
a = [int(sys.stdin.readline().strip()) for x in range(n)]

total = 0

ax = []
for i in a:
    total += i / 2
    ax.append(i % 2)

pre_i = 0
for i in ax:
    if pre_i == 1 and i == 1:
        total += 1
        pre_i = 0
    else:
        pre_i = i

print total

Submission status: Wrong Answer

Solution code:
N = int(raw_input())

A_c = [int(raw_input()) for i in range(N)]

t_pairs = 0
A = []
for i in range(N):
    t_pairs += (A_c[i] - A_c[i]%4)//2
    A_c[i] = A_c[i]%4
    A.extend([i]*A_c[i])

group_count = 1
for i in range(1,len(A)):
    if A[i] - A[i-1] <= 1:
        group_count += 1
    else:
        t_pairs += group_count // 2
        group_count = 0

print (t_pairs + group_count//2)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(raw_input())
A = []
for i in xrange(N):
    A.append(int(raw_input()))
A = np.array(A)
num_pair = (A[A % 2 == 1] / 2).sum()
A[A % 2 == 1] = 1
num_pair += (((A[A > 2] - 2)) / 2).sum()
A[A > 2] = 2
for i in xrange(len(A) - 1):
    if A[i] > 0 and A[i + 1] > 0:
        num_pair += 1
        A[i] -= 1
        A[i + 1] -= 1
num_pair += (A / 2).sum()
print num_pair

Submission status: Wrong Answer

Solution code:
# coding: UTF-8
n = int(raw_input())
a =[]
for var in range(n):
    a.append(int(raw_input()))
pair = 0
flag = True
for now in range(len(a)):

    if a[now] % 2 == 0:
        pair = pair + a[now]/2
        a[now] = 0
    elif a[now] % 2 == 1:
        pair = pair + a[now]/2
        a[now] = 1
        if now == 0 or now == len(a)-1:
            pass
        else:
            if a[now+1]  != 0:
                pair = pair + 1
                a[now+1] = a[now+1]-1
print pair

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(raw_input())
A = []
for i in xrange(N):
    A.append(int(raw_input()))
A = np.array(A)
num_pair = (A[A % 2 == 1] / 2).sum()
A[A % 2 == 1] = 1
num_pair += (((A[A > 2] - 2)) / 2).sum()
A[A > 2] = 2
for i in xrange(len(A) - 1):
    if A[i] > 0 and A[i + 1] > 0:
        num_pair += 1
        A[i] -= 1
        A[i + 1] -= 1
print num_pair

Submission status: Wrong Answer

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

ans = 0
for k in range(1,N-1):
    if A[k-1] %2 == A[k+1] %2 == 1 and A[k] %2 == 0:
        ans += A[k-1]//2
        ans += A[k]//2
        ans += A[k+1]//2
        A[k-1] = 1
        A[k] = 2
        A[k+1] = 1
    else:
        ans += A[k-1]//2
        ans += A[k]//2
        ans += A[k+1]//2
        A[k-1] %= 2
        A[k] %= 2
        A[k+1] %= 2

for k in range(N-1):
    if A[k]*A[k+1] >= 1:
        ans += 1
        A[k] -= 1
        A[k+1] -= 1

print(ans)

Submission status: Wrong Answer

Solution code:
# coding: UTF-8
n = int(raw_input())
a =[]
for var in range(n):
    a.append(int(raw_input()))
pair = 0
flag = True
for now in range((len(a)+1)/2):

    if a[now] % 2 == 0:
        pair = pair + a[now]/2
        a[now] = 0
    elif a[now] % 2 == 1:
        pair = pair + a[now]/2
        a[now] = 1
        if now == 0:
            pass
        else:
            if a[now+1] % 2 != 0:
                pair = pair + 1
                a[now+1] = a[now+1]-1
    if now == len(a)-now-1:
        continue
    if a[len(a)-now-1] % 2 == 0:
        pair = pair + a[len(a)-now-1]/2
        a[len(a)-now-1] = 0
    elif a[len(a)-now-1] % 2 == 1:
        pair = pair + a[len(a)-now-1]/2
        a[len(a)-now-1] = 1
        if now == 0:
            pass
        else:
            if a[len(a)-now-2] % 2 != 0:
                pair = pair + 1
                a[len(a)-now-2] = a[len(a)-now-2] -1
print pair