Problem:


Score : 400 points

Problem Statement

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

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

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

Constraints

1 ≦ N ≦ 10^5

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

All input values are integers.

Input

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

N
A_1
:
A_N

Output

Print the maximum number of pairs that Snuke can create.

Sample Input 1

4
4
0
3
2

Sample Output 1

4

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

Sample Input 2

8
2
0
1
6
0
8
2
1

Sample Output 2

9



Sample input:
4
4
0
3
2


Sample output:
4

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    d={}
    n=int(input())
    for i in range(n):
        d[i+1]=int(input())
    cnt=0
    for k,v in d.items():
        p,mod=divmod(v,2)
        cnt+=p
        d[k]=mod

    loop=0
    for k,v in d.items():
        if loop==0:
            tempk=k
            tempv=v
            loop+=1
        else:
            if k==tempk+1:
                v-=min(v,tempv)
                cnt+=min(v,tempv)
            tempk=k
            tempv=v

    print(cnt)



resolve()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N, *A = map(int, open(0).read().split())
ans = sum(c//2 for c in A)
A = [c%2 for c in A]
for i in range(N-1):
  if A[i]==A[i+1]==1:
    A[i+1] = 0
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N, *A = map(int, open(0).read().split())
ans = sum(c//2 for c in A)
A = [c%2 for c in A]
for i in range(N-2):
  if A[i]==A[i+1]==1:
    A[i+1] = 0
    ans += 1
print(ans)

Submission status: Wrong Answer

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

ans=0
if N==1:
    print(A[0]//2)
    exit()

for i in range(N):
    if i==(N-1):
        ans+=A[i]//2
        break
    if i==0:
        ans+=A[i]//2
        ans+=min(A[i]%2,A[i+1])
        A[i+1]=max(0,A[i+1]-A[i]%2)
        continue
    ans+=A[i]//2
    ans+=min(A[i]%2,A[i+1])
    A[i+1]-=A[i]%2
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

# 直感的に分かる貪欲（下から組を作る）だと思うんだけど、これでdiff1185は数字が高すぎじゃない? 

n = int(input())
nums = [int(input()) for _ in range(n)]

ans = 0
for idx, m in enumerate(nums):
    if m > 0:
        ans += m // 2
        # m -= (m // 2) * 2
        m = m & 1
    if m == 1 and idx != n-1:
        ans += 1
        m -= 1
        nums[idx+1] -= 1

print(ans)

Submission status: Wrong Answer

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

ans = 0
rest = 0
for a in A:
    if rest == 0:
        ans += a // 2
        rest = a % 2
    else:
        if (a + rest) % 2 == 0:
            ans += (a + rest) // 2
            rest = (a + rest) % 2
        else:
            ans += a % 2
            rest = 0

print(ans)

Submission status: Wrong Answer

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

ans = 0
rest = 0
for a in A:
    if rest == 0:
        ans += a // 2
        rest = a % 2
    else:
        if (ans + rest) % 2 == 0:
            ans += (a + rest) // 2
            rest = (a + rest) % 2
        else:
            ans += a % 2
            rest = 0

print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def isOK(S):
    visited = [[False for _ in range(10)]for _ in range(10)]
    sx, sy = 0, 0
    for y in range(10):
        for x in range(10):
            if S[y][x] == 'o':
                sx = x
                sy = y
                break
    q = []
    q.append((sx, sy))
    while q != []:
        x, y = q.pop()
        visited[y][x] = True
        DIR = [(-1, 0), (1, 0), (0, -1), (0, 1)]
        for d in DIR:
            nx, ny = x + d[0], y + d[1]
            if not 0 <= nx < 10:
                continue
            if not 0 <= ny < 10:
                continue
            if visited[ny][nx]:
                continue
            if S[ny][nx] == 'x':
                continue
            q.append((nx, ny))
    for y in range(10):
        for x in range(10):
            if not visited[y][x] and S[y][x] == 'o':
                return False
    return True


def solve():
    N = Scanner.int()
    ans = 0
    tmp = 0
    for _ in range(N):
        A = Scanner.int()
        ans += A // 2
        A = A % 2
        if A + tmp == 2:
            ans += 1
            tmp = 0
        else:
            tmp = A
    print(ans)


def main():
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def isOK(S):
    visited = [[False for _ in range(10)]for _ in range(10)]
    sx, sy = 0, 0
    for y in range(10):
        for x in range(10):
            if S[y][x] == 'o':
                sx = x
                sy = y
                break
    q = []
    q.append((sx, sy))
    while q != []:
        x, y = q.pop()
        visited[y][x] = True
        DIR = [(-1, 0), (1, 0), (0, -1), (0, 1)]
        for d in DIR:
            nx, ny = x + d[0], y + d[1]
            if not 0 <= nx < 10:
                continue
            if not 0 <= ny < 10:
                continue
            if visited[ny][nx]:
                continue
            if S[ny][nx] == 'x':
                continue
            q.append((nx, ny))
    for y in range(10):
        for x in range(10):
            if not visited[y][x] and S[y][x] == 'o':
                return False
    return True


def solve():
    N = Scanner.int()
    ans = 0
    tmp = 0
    for _ in range(N):
        A = Scanner.int()
        ans += A // 2
        if A % 2 == 1:
            if tmp == 1:
                ans += 1
                tmp = 0
            else:
                tmp += 1
        else:
            tmp = 0
    print(ans)


def main():
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
A=[int(input()) for _ in range(n)]
cnt=0
for i in range(n):
    cnt+=A[i]//2
    A[i]%=2
j=0
while j<=n-2:
    if A[j]==1 and A[j+1]==1:
        cnt+=1
        j+=2
    else:
        j+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from math import floor

def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]

    for i in range(n-1):
        if a[i] > a[i+1]:
            small = a[i+1]
            a[i+1] = 0
            a[i] -= small
            yield small + floor(a[i] / 2)
        elif a[i] < a[i+1]:
            small = a[i]
            a[i+1] -= small
            yield small + floor(a[i+1] / 2)
            a[i+1] %= 2
        else:
            yield a[i]
            a[i] = a[i+1] = 0


print(sum(main()))

Submission status: Wrong Answer

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

def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]

    for i in range(n-1):
        if a[i] > a[i+1]:
            small = a[i+1]
            yield small
            a[i+1] = 0
            a[i] -= small
            yield a[i] // 2
        elif a[i] < a[i+1]:
            small = a[i]
            yield small
            a[i+1] -= small
            yield a[i+1] // 2
            a[i+1] %= 2
        else:
            yield a[i]
            a[i] = a[i+1] = 0


print(sum(main()))

Submission status: Wrong Answer

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

def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]

    for i in range(n-1):
        if a[i] >= a[i+1]:
            yield a[i+1]
            a[i+1] = 0
            yield (a[i] - a[i+1]) // 2
        else:
            yield a[i]
            a[i+1] -= a[i]
            yield a[i+1] // 2
            a[i+1] %= 2


print(sum(main()))

Submission status: Wrong Answer

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

def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]

    # for i in range(n-1):
    #     if a[i] >= a[i+1]:
    #         small = a[i+1]
    #         yield small
    #         a[i] -= small
    #         a[i+1] = 0
    #         yield a[i] // 2
    #         a[i] %= 2
    #     else:
    #         small = a[i]
    #         yield small
    #         a[i+1] -= small
    #         a[i] = 0
    #         yield a[i+1] // 2
    #         a[i+1] %= 2

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

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


print(sum(main()))

Submission status: Wrong Answer

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

def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]

    for i in range(n-1):
        if a[i] >= a[i+1]:
            small = a[i+1]
            yield small
            a[i] -= small
            a[i+1] = 0
            yield a[i] // 2
        else:
            small = a[i]
            yield small
            a[i+1] -= small
            yield a[i+1] // 2
            a[i+1] %= 2


print(sum(main()))

Submission status: Wrong Answer

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

def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]

    for i in range(n-1):
        if a[i] > a[i+1]:
            small = a[i+1]
            yield small
            a[i] -= small
            a[i+1] = 0
            yield a[i] // 2
        else:
            small = a[i]
            yield small
            a[i+1] -= small
            yield a[i+1] // 2
            a[i+1] %= 2


print(sum(main()))

Submission status: Wrong Answer

Solution code:
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()
a = nin(n)

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()
a = nin(n)

def main():
    ans = 0
    for i in range(n):
        t = a[i] // 2
        a[i] %= 2
        ans += t
        if i >= 1 and a[i - 1] >= 1:
            t = min(a[i], a[i - 1])
            ans += t
            a[i] -= t
            a[i - 1] -= t
    
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = [INT() for _ in range(N)]
ans = 0
for i in range(N-1):
	if A[i]%2==1 and A[i+1]%2==1:
		tmp = min(A[i], A[i+1])
		A[i] -= tmp
		A[i+1] -= tmp
		ans += tmp
for a in A:
	ans += a//2
print(ans)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = [INT() for _ in range(N)]
ans = 0
for i in range(N-1):
	if A[i] and A[i+1]:
		tmp = min(A[i], A[i+1])
		A[i] -= tmp
		A[i+1] -= tmp
		ans += tmp
for a in A:
	ans += a//2
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = np.array([int(input()) for _ in range(N)])
tot = np.sum(A)
for i in range(N):
    if A[i] % 2 == 1:
        A[i] = 1
    else:
        if A[i] > 2:
            A[i] = 2
        else:
            A[i] = 0

tot_res = np.sum(A)

ans = (tot-tot_res)//2

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

ans  += np.count_nonzero(A==2)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = np.array([int(input()) for _ in range(N)])
tot = np.sum(A)
A %= 2
tot_res = np.sum(A)
ans = (tot - tot_res)//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:
mod = 10 ** 9 + 7
mod2 = 2 ** 61 + 1
from collections import deque
import heapq
from bisect import bisect_left, insort_left, bisect_right

_NUMINT_ALL = list(range(10))


def main():
    ans = solve()

    if ans in [True, False]:
        YesNo(ans)
    elif ans is not None:
        print(ans)


def solve():
    N = iip(False)
    A = iipt(N)

    cur = 0
    ans = 0
    for i in A:
        if cur == 1 and i%2 >= 1:
            ans += 1
            i -= 1

        ans += i//2
        cur = i%2


    print(ans)




#####################################################ライブラリ集ここから

def iip(listed=True, num_only=True):  # 数字のinputをlistで受け取る
    if num_only:
        ret = [int(i) for i in input().split()]
    else:
        ret = [int(i) if i in _NUMINT_ALL else i for i in input().split()]

    if len(ret) == 1 and not listed:
        return ret[0]
    return ret


def saidai_kouyakusuu(A):  # 最大公約数
    l = len(A)
    while True:
        m = min(A)
        mx = max(A)
        if m == mx:
            return m

        for i in range(l):
            if A[i] % m == 0:
                A[i] = m
            else:
                A[i] %= m


def sort_tuples(l, index):  # タプルのリストを特定のインデックスでソートする
    if isinstance(l, list):
        l.sort(key=lambda x: x[index])
        return l
    else:
        l = list(l)
        return sorted(l, key=lambda x: x[index])


def count_elements(l):  # リストの中身の個数を種類分けして辞書で返す
    d = {}
    for i in l:
        if i in d:
            d[i] += 1
        else:
            d[i] = 1
    return d


def safeget(l, index, default="exception"):  # listの中身を取り出す時、listからはみ出たり
    if index >= len(l):                      # マイナスインデックスになったりするのを防ぐ
        if default == "exception":
            raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。配列の長さは", len(l), "です"]))
        else:
            return default
    elif index < 0:
        if default == "exception":
            raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。負の値は許可されていません"]))
        else:
            return default
    else:
        return l[index]


def iipt(l, listed=False, num_only=True):  # 縦向きに並んでいるデータをリストに落とし込む(iip利用)
    ret = []
    for i in range(l):
        ret.append(iip(listed=listed, num_only=num_only))
    return ret


def sortstr(s):  # 文字列をソートする
    return "".join(sorted(s))


def iip_ord(startcode="a"):  # 文字列を数字の列に変換する(数字と文字は1:1対応)
    if isinstance(startcode, str):
        startcode = ord(startcode)
    return [ord(i) - startcode for i in input()]


def YesNo(s):  # TrueFalseや1, 0をYesNoに変換する
    if s:
        print("Yes")
    else:
        print("No")


def fprint(s):  # リストを平たくしてprintする(二次元リストを見やすくしたりとか)
    for i in s:
        print(i)


def bitall(N):  # ビット全探索用のインデックスを出力
    ret = []
    for i in range(2 ** N):
        a = []
        for j in range(N):
            a.append(i % 2)
            i //= 2
        ret.append(a)
    return ret

def split_print_space(s):  # リストの中身をスペース区切りで出力する
    print(" ".join([str(i) for i in s]))


def split_print_enter(s):  # リストの中身を改行区切りで出力する
    print("\n".join([str(i) for i in s]))


def soinsuu_bunkai(n):  # 素因数分解
    ret = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):  # nCrをmodを使って計算する
    if n <= 0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n - r + 1, n + 1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r + 1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        # print(f"{n}C{r} = {ret}")
        pass
    return ret


def inv(n, mod):  #  modnにおける逆元を計算
    return power(n, mod - 2)


def power(n, p, mod_=mod):  # 繰り返し二乗法でn**p % modを計算
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p // 2, mod_) ** 2) % mod_
    if p % 2 == 1:
        return (n * power(n, p - 1, mod_)) % mod_


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
mod = 10 ** 9 + 7
mod2 = 2 ** 61 + 1
from collections import deque
import heapq
from bisect import bisect_left, insort_left, bisect_right

_NUMINT_ALL = list(range(10))


def main():
    ans = solve()

    if ans in [True, False]:
        YesNo(ans)
    elif ans is not None:
        print(ans)


def solve():
    N = iip(False)
    A = iipt(N)

    cur = 0
    ans = 0
    for i in A:
        ans += i//2
        i %= 2
        ans += min(cur, i)
        cur = i-min(cur,i)

    print(ans)




#####################################################ライブラリ集ここから

def iip(listed=True, num_only=True):  # 数字のinputをlistで受け取る
    if num_only:
        ret = [int(i) for i in input().split()]
    else:
        ret = [int(i) if i in _NUMINT_ALL else i for i in input().split()]

    if len(ret) == 1 and not listed:
        return ret[0]
    return ret


def saidai_kouyakusuu(A):  # 最大公約数
    l = len(A)
    while True:
        m = min(A)
        mx = max(A)
        if m == mx:
            return m

        for i in range(l):
            if A[i] % m == 0:
                A[i] = m
            else:
                A[i] %= m


def sort_tuples(l, index):  # タプルのリストを特定のインデックスでソートする
    if isinstance(l, list):
        l.sort(key=lambda x: x[index])
        return l
    else:
        l = list(l)
        return sorted(l, key=lambda x: x[index])


def count_elements(l):  # リストの中身の個数を種類分けして辞書で返す
    d = {}
    for i in l:
        if i in d:
            d[i] += 1
        else:
            d[i] = 1
    return d


def safeget(l, index, default="exception"):  # listの中身を取り出す時、listからはみ出たり
    if index >= len(l):                      # マイナスインデックスになったりするのを防ぐ
        if default == "exception":
            raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。配列の長さは", len(l), "です"]))
        else:
            return default
    elif index < 0:
        if default == "exception":
            raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。負の値は許可されていません"]))
        else:
            return default
    else:
        return l[index]


def iipt(l, listed=False, num_only=True):  # 縦向きに並んでいるデータをリストに落とし込む(iip利用)
    ret = []
    for i in range(l):
        ret.append(iip(listed=listed, num_only=num_only))
    return ret


def sortstr(s):  # 文字列をソートする
    return "".join(sorted(s))


def iip_ord(startcode="a"):  # 文字列を数字の列に変換する(数字と文字は1:1対応)
    if isinstance(startcode, str):
        startcode = ord(startcode)
    return [ord(i) - startcode for i in input()]


def YesNo(s):  # TrueFalseや1, 0をYesNoに変換する
    if s:
        print("Yes")
    else:
        print("No")


def fprint(s):  # リストを平たくしてprintする(二次元リストを見やすくしたりとか)
    for i in s:
        print(i)


def bitall(N):  # ビット全探索用のインデックスを出力
    ret = []
    for i in range(2 ** N):
        a = []
        for j in range(N):
            a.append(i % 2)
            i //= 2
        ret.append(a)
    return ret

def split_print_space(s):  # リストの中身をスペース区切りで出力する
    print(" ".join([str(i) for i in s]))


def split_print_enter(s):  # リストの中身を改行区切りで出力する
    print("\n".join([str(i) for i in s]))


def soinsuu_bunkai(n):  # 素因数分解
    ret = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):  # nCrをmodを使って計算する
    if n <= 0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n - r + 1, n + 1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r + 1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        # print(f"{n}C{r} = {ret}")
        pass
    return ret


def inv(n, mod):  #  modnにおける逆元を計算
    return power(n, mod - 2)


def power(n, p, mod_=mod):  # 繰り返し二乗法でn**p % modを計算
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p // 2, mod_) ** 2) % mod_
    if p % 2 == 1:
        return (n * power(n, p - 1, mod_)) % mod_


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    a = IR(n)
    ans = 0
    for i in range(n - 1):
        t = min(a[i], a[i + 1])
        ans += t
        a[i] -= t
        a[i + 1] -= t
    for i in range(n):
        ans += a[i] >> 1
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    a = IR(n)
    ans = 0
    for i in range(n):
        ans += a[i] // 2
        a[i] = a[i] & 1
    for i in range(n-1):
        if a[i] + a[i + 1] == 2:
            ans += 1
        a[i + 1] = 0
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
A = []
for i in range(N):
    A.append(int(input()))
    
ans = 0

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
A = []
for i in range(N):
    A.append(int(input()))
    
ans = 0

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