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:
def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    ans = 0
    for i in range(n):
        if a[i] == 0:
            continue
        ans = a[i]//2
        if i != n-1 and a[i]&1 and a[i+1] != 0:
            ans += 1
            a[i+1] -= 1
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    changing = [a[0]]
    direct_flag = False #False > True <
    ans = (0 if n != 1 else a[0]//2)
    for i in range(1,n):
        if len(changing) == 1:
            changing.append(a[i])
            if changing[0] <= changing[1]:
                direct_flag = True
        else:
            if direct_flag and changing[-1] <= a[i]:
                changing.append(a[i])
            elif not direct_flag and changing[-1] > a[i]:
                changing.append(a[i])
            else:
                m = len(changing)
                iterange = (range(m) if direct_flag else range(m)[::-1])
                for j in iterange:
                    if j != 0:
                        makable = min(changing[j-1],changing[j])
                        ans += makable
                        changing[j-1] -= makable
                        changing[j] -= makable
                    if j != m-1:
                        makable = min(changing[j],changing[j+1])
                        ans += makable
                        changing[j] -= makable
                        changing[j+1] -= makable
                    if changing[j] >= 2:
                        makable = changing[j] // 2
                        ans += makable
                        changing[j] -= makable * 2
                makable = min(changing[-1],a[i])
                ans += makable
                changing = [a[i] - makable]
                direct_flag = False
        if i == n-1:
            if len(changing) == 1:
                ans += changing[0] // 2
            else:
                m = len(changing)
                iterange = (range(m) if direct_flag else range(m)[::-1])
                for j in iterange:
                    if j != 0:
                        makable = min(changing[j-1],changing[j])
                        ans += makable
                        changing[j-1] -= makable
                        changing[j] -= makable
                    if j != m-1:
                        makable = min(changing[j],changing[j+1])
                        ans += makable
                        changing[j] -= makable
                        changing[j+1] -= makable
                    if changing[j] >= 2:
                        makable = changing[j] // 2
                        ans += makable
                        changing[j] -= makable * 2
    ans2 = 0
    for i in range(n):
        if a[i]%2 == 0:
            ans2 += a[i]//2
            a[i] = 0
    changing = [a[0]]
    direct_flag = False
    for i in range(1,n):
        if len(changing) == 1:
            changing.append(a[i])
            if changing[0] <= changing[1]:
                direct_flag = True
        else:
            if direct_flag and changing[-1] <= a[i]:
                changing.append(a[i])
            elif not direct_flag and changing[-1] > a[i]:
                changing.append(a[i])
            else:
                m = len(changing)
                iterange = (range(m) if direct_flag else range(m)[::-1])
                for j in iterange:
                    if j != 0:
                        makable = min(changing[j-1],changing[j])
                        ans2 += makable
                        changing[j-1] -= makable
                        changing[j] -= makable
                    if j != m-1:
                        makable = min(changing[j],changing[j+1])
                        ans2 += makable
                        changing[j] -= makable
                        changing[j+1] -= makable
                    if changing[j] >= 2:
                        makable = changing[j] // 2
                        ans2 += makable
                        changing[j] -= makable * 2
                makable = min(changing[-1],a[i])
                ans2 += makable
                changing = [a[i] - makable]
                direct_flag = False
        if i == n-1:
            if len(changing) == 1:
                ans2 += changing[0] // 2
            else:
                m = len(changing)
                iterange = (range(m) if direct_flag else range(m)[::-1])
                for j in iterange:
                    if j != 0:
                        makable = min(changing[j-1],changing[j])
                        ans2 += makable
                        changing[j-1] -= makable
                        changing[j] -= makable
                    if j != m-1:
                        makable = min(changing[j],changing[j+1])
                        ans2 += makable
                        changing[j] -= makable
                        changing[j+1] -= makable
                    if changing[j] >= 2:
                        makable = changing[j] // 2
                        ans2 += makable
                        changing[j] -= makable * 2
    print(max(ans,ans2))
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    changing = [a[0]]
    direct_flag = False #False > True <
    ans = (0 if n != 1 else a[0]//2)
    for i in range(1,n):
        if len(changing) == 1:
            changing.append(a[i])
            if changing[0] <= changing[1]:
                direct_flag = True
        else:
            if direct_flag and changing[-1] <= a[i]:
                changing.append(a[i])
            elif not direct_flag and changing[-1] > a[i]:
                changing.append(a[i])
            else:
                m = len(changing)
                iterange = (range(m) if direct_flag else range(m)[::-1])
                for j in iterange:
                    if j != 0:
                        makable = min(changing[j-1],changing[j])
                        ans += makable
                        changing[j-1] -= makable
                        changing[j] -= makable
                    if j != m-1:
                        makable = min(changing[j],changing[j+1])
                        ans += makable
                        changing[j] -= makable
                        changing[j+1] -= makable
                    if changing[j] >= 2:
                        makable = changing[j] // 2
                        ans += makable
                        changing[j] -= makable * 2
                makable = min(changing[-1],a[i])
                ans += makable
                changing = [a[i] - makable]
                direct_flag = False
        if i == n-1:
            if len(changing) == 1:
                ans += changing[0] // 2
            else:
                m = len(changing)
                iterange = (range(m) if direct_flag else range(m)[::-1])
                for j in iterange:
                    if j != 0:
                        makable = min(changing[j-1],changing[j])
                        ans += makable
                        changing[j-1] -= makable
                        changing[j] -= makable
                    if j != m-1:
                        makable = min(changing[j],changing[j+1])
                        ans += makable
                        changing[j] -= makable
                        changing[j+1] -= makable
                    if changing[j] >= 2:
                        makable = changing[j] // 2
                        ans += makable
                        changing[j] -= makable * 2
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    changing = [a[0]]
    direct_flag = False #False > True <
    ans = (0 if n != 1 else a[0]//2)
    for i in range(1,n):
        if len(changing) == 1:
            changing.append(a[i])
            if changing[0] <= changing[1]:
                direct_flag = True
        else:
            if direct_flag and changing[-1] <= a[i]:
                changing.append(a[i])
            elif not direct_flag and changing[-1] > a[i]:
                changing.append(a[i])
            else:
                m = len(changing)
                iterange = (range(m) if direct_flag else range(m)[::-1])
                for j in iterange:
                    if j != 0:
                        makable = min(changing[j-1],changing[j])
                        ans += makable
                        changing[j-1] -= makable
                        changing[j] -= makable
                    if j != m-1:
                        makable = min(changing[j],changing[j+1])
                        ans += makable
                        changing[j] -= makable
                        changing[j+1] -= makable
                    if changing[j] >= 2:
                        makable = changing[j] // 2
                        ans += makable
                        changing[j] -= makable * 2
                makable = min(changing[-1],a[i])
                ans += makable
                changing = [a[i] - makable]
                direct_flag = False
        if i == n-1:
            if len(changing) == 1:
                ans += changing[0] // 2
            else:
                m = len(changing)
                iterange = (range(m) if direct_flag else range(m)[::-1])
                for j in iterange:
                    if j != 0:
                        makable = min(changing[j-1],changing[j])
                        ans += makable
                        changing[j-1] -= makable
                        changing[j] -= makable
                    if j != m-1:
                        makable = min(changing[j],changing[j+1])
                        ans += makable
                        changing[j] -= makable
                        changing[j+1] -= makable
                    if changing[j] >= 2:
                        makable = changing[j] // 2
                        ans += makable
                        changing[j] -= makable * 2
    ans2 = 0
    for i in range(n):
        if a[i]%2 == 0:
            ans2 += a[i]//2
            a[i] = 0
        elif i != 0 and a[i-1]&1:
            makable = min(a[i-1],a[i])
            ans2 += makable
            a[i-1] -= makable
            a[i] -= makable
        elif i != n-1 and a[i+1]&1:
            makable = min(a[i],a[i+1])
            ans2 += makable
            a[i] -= makable
            a[i+1] -= makable
    for i in range(n):
        if i != 0:
            makable = min(a[i-1],a[i])
            ans2 += makable
            a[i-1] -= makable
            a[i] -= makable
        if i != n-1:
            makable = min(a[i],a[i+1])
            ans2 += makable
            a[i] -= makable
            a[i+1] -= makable
        if a[i] >= 2:
            makable = a[i] // 2
            ans2 += makable
            a[i] -= makable * 2
    print(max(ans,ans2))
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    changing = [a[0]]
    direct_flag = False #False > True <
    ans = (0 if n != 1 else a[0]//2)
    for i in range(1,n):
        if len(changing) == 1:
            changing.append(a[i])
            if changing[0] < changing[1]:
                direct_flag = True
        else:
            if direct_flag and changing[-1] < a[i]:
                changing.append(a[i])
            elif not direct_flag and changing[-1] > a[i]:
                changing.append(a[i])
            else:
                m = len(changing)
                iterange = (range(m) if direct_flag else range(m)[::-1])
                for j in iterange:
                    if j != 0:
                        makable = min(changing[j-1],changing[j])
                        ans += makable
                        changing[j-1] -= makable
                        changing[j] -= makable
                    if j != m-1:
                        makable = min(changing[j],changing[j+1])
                        ans += makable
                        changing[j] -= makable
                        changing[j+1] -= makable
                    if changing[j] >= 2:
                        makable = changing[j] // 2
                        ans += makable
                        changing[j] -= makable * 2
                changing = [a[i]]
                direct_flag = False
        if i == n-1:
            if len(changing) == 1:
                ans += changing[0] // 2
            else:
                m = len(changing)
                iterange = (range(m) if direct_flag else range(m)[::-1])
                for j in iterange:
                    if j != 0:
                        makable = min(changing[j-1],changing[j])
                        ans += makable
                        changing[j-1] -= makable
                        changing[j] -= makable
                    if j != m-1:
                        makable = min(changing[j],changing[j+1])
                        ans += makable
                        changing[j] -= makable
                        changing[j+1] -= makable
                    if changing[j] >= 2:
                        makable = changing[j] // 2
                        ans += makable
                        changing[j] -= makable * 2
    ans2 = 0
    for i in range(n):
        if a[i]%2 == 0:
            ans2 = a[i] // 2
            a[i] -= a[i]
        elif a[i]%2 != 0:
            if i == 0 or a[i-1]%2 == 0:
                continue
            else:
                ans2 += min(a[i-1],a[i])
                a[i-1] -= min(a[i-1],a[i])
                a[i] -= min(a[i-1],a[i])
                if a[i-1]%2 == 0:
                    ans2 += a[i-1]//2
                    a[i-1] -= a[i-1]
    changing = [a[0]]
    direct_flag = False #False > True <
    for i in range(1,n):
        if len(changing) == 1:
            changing.append(a[i])
            if changing[0] < changing[1]:
                direct_flag = True
        else:
            if direct_flag and changing[-1] < a[i]:
                changing.append(a[i])
            elif not direct_flag and changing[-1] > a[i]:
                changing.append(a[i])
            else:
                m = len(changing)
                iterange = (range(m) if direct_flag else range(m)[::-1])
                for j in iterange:
                    if j != 0:
                        makable = min(changing[j-1],changing[j])
                        ans2 += makable
                        changing[j-1] -= makable
                        changing[j] -= makable
                    if j != m-1:
                        makable = min(changing[j],changing[j+1])
                        ans2 += makable
                        changing[j] -= makable
                        changing[j+1] -= makable
                    if changing[j] >= 2:
                        makable = changing[j] // 2
                        ans2 += makable
                        changing[j] -= makable * 2
                changing = [a[i]]
                direct_flag = False
        if i == n-1:
            if len(changing) == 1:
                ans2 += changing[0] // 2
            else:
                m = len(changing)
                iterange = (range(m) if direct_flag else range(m)[::-1])
                for j in iterange:
                    if j != 0:
                        makable = min(changing[j-1],changing[j])
                        ans2 += makable
                        changing[j-1] -= makable
                        changing[j] -= makable
                    if j != m-1:
                        makable = min(changing[j],changing[j+1])
                        ans2 += makable
                        changing[j] -= makable
                        changing[j+1] -= makable
                    if changing[j] >= 2:
                        makable = changing[j] // 2
                        ans2 += makable
                        changing[j] -= makable * 2
    print(max(ans,ans2))
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    changing = [a[0]]
    direct_flag = False #False > True <
    ans = (0 if n != 1 else a[0]//2)
    for i in range(1,n):
        if len(changing) == 1:
            changing.append(a[i])
            if changing[0] < changing[1]:
                direct_flag = True
        else:
            if direct_flag and changing[-1] < a[i]:
                changing.append(a[i])
            elif not direct_flag and changing[-1] > a[i]:
                changing.append(a[i])
            else:
                m = len(changing)
                iterange = (range(m) if direct_flag else range(m)[::-1])
                for j in iterange:
                    if j != 0:
                        makable = min(changing[j-1],changing[j])
                        ans += makable
                        changing[j-1] -= makable
                        changing[j] -= makable
                    if j != m-1:
                        makable = min(changing[j],changing[j+1])
                        ans += makable
                        changing[j] -= makable
                        changing[j+1] -= makable
                    if changing[j] >= 2:
                        makable = changing[j] // 2
                        ans += makable
                        changing[j] -= makable * 2
                changing = [a[i]]
                direct_flag = False
        if i == n-1:
            if len(changing) == 1:
                ans += changing[0] // 2
            else:
                m = len(changing)
                iterange = (range(m) if direct_flag else range(m)[::-1])
                for j in iterange:
                    if j != 0:
                        makable = min(changing[j-1],changing[j])
                        ans += makable
                        changing[j-1] -= makable
                        changing[j] -= makable
                    if j != m-1:
                        makable = min(changing[j],changing[j+1])
                        ans += makable
                        changing[j] -= makable
                        changing[j+1] -= makable
                    if changing[j] >= 2:
                        makable = changing[j] // 2
                        ans += makable
                        changing[j] -= makable * 2
    ans2 = 0
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    a_save = a[:]
    ans1 = 0
    ans2 = 0
    for i in range(n):
        if i != 0:
            makable = min(a[i-1],a[i])
            ans1 += makable
            a[i-1] -= makable
            a[i] -= makable
        if i != n-1:
            makable = min(a[i],a[i+1])
            ans1 += makable
            a[i] -= makable
            a[i+1] -= makable
        if a[i] >= 2:
            makable = a[i] // 2
            ans1 += makable
            a[i] -= makable * 2
    a = a_save[:]
    for i in range(n)[::-1]:
        if i != 0:
            makable = min(a[i-1],a[i])
            ans2 += makable
            a[i-1] -= makable
            a[i] -= makable
        if i != n-1:
            makable = min(a[i],a[i+1])
            ans2 += makable
            a[i] -= makable
            a[i+1] -= makable
        if a[i] >= 2:
            makable = a[i] // 2
            ans2 += makable
            a[i] -= makable * 2
    print(max(ans1,ans2))
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    ans = 0
    for i in range(n):
        if i != 0:
            makable = min(a[i-1],a[i])
            ans += makable
            a[i-1] -= makable
            a[i] -= makable
        if i != n-1:
            makable = min(a[i],a[i+1])
            ans += makable
            a[i] -= makable
            a[i+1] -= makable
        if a[i] >= 2:
            makable = a[i] // 2
            ans += makable
            a[i] -= makable * 2
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[int(input()) for i in range(n)]
ans=0
for i in range(len(l)-1):
    ans+=l[i]//2
    l[i]=l[i]%2
    tmp=min(l[i],l[i+1])
    ans+=tmp
    l[i+1]-=tmp
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(len(l)-1):
    tmp=min(l[i],l[i+1])
    ans+=tmp
    l[i]-=tmp
    l[i+1]-=tmp
    ans+=l[i]//2
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [(i+1,int(input())) for i in range(N)]
last = 0
cnt = 0
for a in A:
    cnt += a[1]//2
    if(a[1]%2==1):
        if(last==1):
            cnt += 1
            last = 0
        else:
            last = 1
    else:
        last = 0
print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [0]*N
ans = 0
for i in range(N):
    A[i] = int(input())
    if A[i] == 0:
        continue

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

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[0]*N
ans=0
for i in range(N):
  A[i]=int(input())
  if A[i] // 2 > 0:
    ans+=A[i]//2
    A[i]-=(A[i]//2)*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())
a = list(int(input()) for _ in range(n))

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

    c += a[i] // 2
    a[i] %= 2

    
print(c)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(int(input()) for _ in range(n))

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

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

print(c)

Submission status: Wrong Answer

Solution code:
N=int(input())
l=[]

for i in range(N):
    l.append(int(input()))

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

Submission status: Wrong Answer

Solution code:
N=int(input())
l=[]

for i in range(N):
    l.append(int(input()))

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

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())

A = [0] * N
count = 0
for n in range(N):
    A[n] = int(input())

if all(A):
    print(sum(A) // 2)
    sys.exit()

index = 0
for n in range(N):
    if A[n] == 0:
        count += sum(A[index: n + 1])
        index = n
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())

A = [0] * N
count = 0
for n in range(N):
    A[n] = int(input())

for n in range(N - 1):
    count += A[n] // 2
    if A[n] % 2 and A[n + 1] != 0:
        A[n] = 0
        A[n + 1] -= 1
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
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)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():

    return

#B
def B():
    n = I()
    a = IR(n)
    ans = 0
    b = [0]*(n+1)
    for i in range(n):
        ans += (a[i]+b[i])>>1
        if (a[i]%2)^(b[i]%2):
            b[i+1] += 1
    print(ans)
    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    B()

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
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)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():

    return

#B
def B():
    n = I()
    a = IR(n)
    ans = 0
    b = [0]*(n+1)
    for i in range(n):
        ans += (a[i]+b[i])>>1
        if a[i]%2 and not b[i]%2:
            b[i+1] += 1
    print(ans)
    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    B()

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
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)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():

    return

#B
def B():
    n = I()
    a = IR(n)
    ans = 0
    b = [0]*(n+1)
    for i in range(n):
        ans += (a[i]+b[i])>>1
        b[i+1] += a[i]%2
    print(ans)
    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    B()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [0] * N
count = 0
for n in range(N):
    num = int(input())
    count += num // 2
    A[n] = num % 2

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

Submission status: Wrong Answer

Solution code:
N, *A = map(int, open(0).read().split())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
arr1 = [0 for i in range(n+1)]

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

arr = arr1.copy()
ans = 0
for i in range(n):
    p = min(arr[i],arr[i+1])
    arr[i]-=p
    arr[i+1]-=p
    ans += p
    ans += arr[i]//2



arr = arr1.copy()
ans1 = 0
for i in range(n-1):
    p = min(arr[-i-2],arr[-i-3])
    arr[-i-2]-=p
    arr[-i-3]-=p
    ans1 += p
    ans1 += arr[-i-2]//2

ans1 += arr[0]//2

# print(ans1)
print(max(ans,ans1))

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = [0 for i in range(n+1)]

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

ans = 0
for i in range(n):
    p = min(arr[i],arr[i+1])
    arr[i]-=p
    arr[i+1]-=p
    ans += p
    ans += arr[i]//2

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(int(input()) for _ in range(N))
ans=0
for _ in range(N-1):
    if A[_]>=2:
        ans+=A[_]//2
        A[_]=A[_]%2
    if A[_]==1 and A[_+1]>=1:
        ans+=1
        A[_+1]-=1
print(ans)

Submission status: Wrong Answer

Solution code:
# AGC003B - Simplified mahjong
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = list(map(int, [input() for _ in range(N)])) + [0]
    ans = 0
    for i in range(N - 1):  # make pairs greedily
        ans += A[i] // 2  # pairs with same cards
        if A[i] % 2 and A[i + 1]:  # pairs with a neighbor
            ans += 1
            A[i + 1] -= 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# AGC003B - Simplified mahjong
def main():
    N = int(input())
    A = list(map(int, [input() for _ in range(N)]))
    ans = 0
    for i in range(N - 1):  # make pairs greedily
        x = min(A[i], A[i + 1])  # pairs with a neighbor
        A[i] -= x
        A[i + 1] -= x
        ans += x + A[i] // 2  # pairs with a neighbor and the same cards
    ans += A[-1] // 2  # pairs with the same cards in the last one
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# AGC003B - Simplified mahjong
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = list(map(int, [input() for _ in range(N)]))
    ans = 0
    for i in range(N - 1):  # make pairs greedily
        x = min(A[i], A[i + 1])  # pairs with a neighbor
        A[i] -= x
        A[i + 1] -= x
        ans += x + A[i] // 2  # pairs with the same cards
        A[i] %= 2
    print(ans)


if __name__ == "__main__":
    main()

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)] + [0]

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

    print(ans)

sol()