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 = []
for i in range(N):
    a.append(int(input()))
#
count = 0
for i in range(N):
    count += a[i]//2
    a[i] = a[i]%2

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

Submission status: Wrong Answer

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

def solve(N: int, A: "List[int]"):
    answer = 0
    for i in range(N):
        answer += A[i]//2
        A[i] %= 2
    
    for i in range(N-1):
        if A[i] == 1 and A[i+1] == 1:
            answer += 1
            A[i] = 0
            A[i+1] = 0
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def solve(N: int, A: "List[int]"):
    answer = 0
    for i in range(N):
        quo,mod = divmod(A[i],2)
        answer += quo
        A[i] = mod
    
    for i in range(N-1):
        if A[i] == 1 and A[i+1] == 1:
            answer += 1
            A[i] = 0
            A[i+1] = 0
    print(answer)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    N = II()
    
    ans = 0
    isPreEven = False

    for _ in range(N):
        a = II()
        ans += a // 2
        if a % 2 == 1:
            if isPreEven:
                ans += 1
                isPreEven = False
            else:
                isPreEven = True
        else:
            isPreEven = False
    
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
INF = 10 ** 10
MOD = 10 ** 9 + 7
from functools import lru_cache
sys.setrecursionlimit(100000000)

def main():
    n = int(input())
    ans = 0
    before = 0
    for _ in range(n):
        a = int(input())
        ans += a//2
        if (a%2) and before :
            ans += 1
            before = 0
        else:
            before = a%2

    print(ans)
if __name__ =='__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
INF = 10 ** 10
MOD = 10 ** 9 + 7
from functools import lru_cache
sys.setrecursionlimit(100000000)

def main():
    n = int(input())
    ans = 0
    before = 0
    for _ in range(n):
        a = int(input())
        ans += a//2
        if (a%2) and before :
            ans += 1
            before = 0
        else:
            before = a%2
    print(ans)

if __name__ =='__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
INF = 10 ** 10
MOD = 10 ** 9 + 7
from functools import lru_cache
sys.setrecursionlimit(100000000)

def main():
    n = int(input())
    ans = 0
    before = 0
    for _ in range(n):
        a = int(input())
        ans += a//2
        if a%2 and before :
            ans += 1
            before = 0
        else:
            before = a%2
    print(ans)

if __name__ =='__main__':
    main()

Submission status: Wrong Answer

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

Submission status: Wrong Answer

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

Submission status: Wrong Answer

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

Submission status: Wrong Answer

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = [I() for _ in range(n)]
ans = 0
for i in range(n):
    if i == 0:
        ans += a[i] // 2
        a[i] = a[i] % 2
    elif i < n-1:
        ans += (a[i] + a[i-1]) // 2
        if a[i-1] == 1 and a[i] % 2:
            a[i] = 0
        else:
            a[i] = a[i] % 2
    else:
        ans += (a[i] + a[i-1]) // 2
print(ans)

Submission status: Wrong Answer

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = [I() for _ in range(n)]
ans = 0
for i in range(n):
    if i == 0:
        ans += a[i] // 2
        a[i] = a[i] % 2
    elif i < n-1:
        ans += (a[i] + a[i-1]) // 2
        if a[i-1] == 1 and a[i] % 2:
            a[i] = 0
        else:
            a[i] = a[i] % 2
    else:
        ans += a[i] // 2
print(ans)

Submission status: Wrong Answer

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = [I() for _ in range(n)]
ans = 0
for i in range(n):
    if i == 0:
        ans += a[i] // 2
        a[i] = a[i] % 2
    elif i < n-1:
        ans += (a[i] + a[i-1]) // 2
        a[i] = (a[i] + a[i-1]) % 2
    else:
        ans += a[i] // 2
print(ans)

Submission status: Wrong Answer

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = [I() for _ in range(n)]
ans = 0
for i in range(n):
    if i == 0:
        ans += a[i] // 2
        a[i] = a[i] % 2
    elif i < n-1:
        ans += (a[i] + a[i-1]) // 2
        a[i] = a[i] % 2
    else:
        ans += a[i] // 2
print(ans)

Submission status: Wrong Answer

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = [I() for _ in range(n)]
b = [0]*n
ans = 0
for i in range(n):
    ans += (a[i] + b[i]) // 2
    if i < n-1:
        b[i+1] += a[i] % 2

print(ans)

Submission status: Wrong Answer

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

ans = 0
for i in range(n-1):
    m = max(A[i], A[i+1])
    ans += m
    A[i] -= m
    A[i+1] -= m


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

Submission status: Wrong Answer

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

ans = 0
for i in range(n - 1):
    pair1 = a[i] // 2
    a[i] -= pair1 * 2
    pair2 = min(a[i], a[i+1])
    ans += pair1 + pair2
    a[i+1] -= pair2

print(ans)

Submission status: Wrong Answer

Solution code:
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True  and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = [0]
for i in range(1,n+1):
    a.append(inn())
ddprint(a)
sm = 0
while len(a)>0:
    sm += a[-1]//2
    if len(a)>1 and a[-1]%2==1 and a[-1]==a[-2]+1 and a[-2]>0:
        sm += 1
        a[-2] -= 1
    a.pop()
print(sm)

Submission status: Wrong Answer

Solution code:
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True  and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = [0]
for i in range(1,n+1):
    a.append(inn())
ddprint(a)
sm = 0
while len(a)>0:
    sm += a[-1]//2
    if len(a)>1 and a[-1]%2==1 and a[-1]==a[-2]+1:
        sm += 1
        a[-2] -= 1
    a.pop()
print(sm)

Submission status: Wrong Answer

Solution code:
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True  and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
h = {}
for i in range(n):
    x = inn()
    h[i] = x
ddprint(h)
sm = 0
a = []
for x in h:
    sm += h[x]//2
    if h[x]%2==1:
        a.append(x)
a.sort()
ddprint(sm)
ddprint(a)
while len(a)>1:
    if a[-1]==a[-2]+1:
        sm += 1
        a.pop()
        a.pop()
    else:
        a.pop()
print(sm)

Submission status: Wrong Answer

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

N = int(input())
A = list(int(input()) for _ in range(N))

s = 0
lastFlag = 0

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

    if lastFlag > 0 and a%2 == 1:
        s += 1
        lastFlag = 0
    else:
        lastFlag = a%2

print(s)

Submission status: Wrong Answer

Solution code:
N,*A=map(int, open(0).read().split())
acc=A[0]
ans=0
for a in A[1:]:
    b=min(acc,a)
    acc-=b
    ans+=b+acc//2
    acc=a-b
ans+=acc//2
print(ans)

Submission status: Wrong Answer

Solution code:
N,*A=map(int, open(0).read().split())
acc=A[0]
ans=0
for a in A[1:]:
    b=min(acc,a)
    acc-=b
    ans+=b+acc//2
    acc=a-b
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
import itertools

mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

N = ni()
A = list()
for _ in range(N):
    A.append(ni())
cnt = 0
s = sum(A)
for i in range(N-1):
    #print(A)
    ccnt = (A[i] + A[i+1]) //2
    A[i+1] -= max(0, ccnt*2 - A[i])
    A[i] = max(0, A[i]-ccnt*2)
    cnt += ccnt
#print(A)
#print(cnt)
print((s - sum(A))//2)

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
import itertools

mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

N = ni()
A = list()
for _ in range(N):
    A.append(ni())
cnt = 0

for i in range(N-1):
    #print(A)
    ccnt = (A[i] + A[i+1]) //2
    A[i+1] -= max(0, ccnt*2 - A[i])
    A[i] = max(0, A[i]-ccnt*2)
    cnt += ccnt
#print(A)
print(cnt)

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
import itertools

mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

N = ni()
A = list()
for _ in range(N):
    A.append(ni())
cnt = 0
for i in range(N-1):
    ccnt = (A[i] + A[i+1]) //2
    A[i+1] -= max(0, ccnt*2 - A[i])
    A[i] = 0
    cnt += ccnt
print(cnt)

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
import itertools

mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

N = ni()
A = list()
for _ in range(N):
    A.append(ni())
cnt = 0
for i in range(N-1):
    ccnt = (A[i] + A[i+1]) //2
    A[i+1] = max(0, A[i+1] - ccnt*2 - A[i])
    A[i] = max(0, A[i] - ccnt*2)
    cnt += ccnt
print(cnt)

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
import itertools

mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

N = ni()
A = list()
for _ in range(N):
    A.append(ni())
cnt = 0
for i in range(N-1):
    ccnt = (A[i] + A[i+1]) //2
    A[i+1] = max(0, A[i+1] - ccnt*2 - A[i])
    #A[i] = max(0, A[i] - ccnt*2)
    cnt += ccnt
print(cnt)

Submission status: Wrong Answer

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    A=LIN(N)
    ans = 0
    for i in range(N-1):
        ans += A[i]//2
        A[i]&=1
        use = min(A[i],A[i+1])
        ans += use 
        A[i+1]-= use 
        A[i]-= use 
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    A=[int(input()) for i in range(N)]+[0]
    ans=0
    for i in range(N):
        if A[i+1]>0 and A[i]>0:
            tmp=min(A[i+1],A[i])
            if A[i+1]%2==1 and A[i]%2==0:
                tmp-=1
            ans+=tmp
            A[i+1]-=tmp
            if A[i]-tmp>=2:
                ans+=(A[i]-tmp)//2
        elif A[i]>=2:
            ans+=A[i]//2
    print(ans)
    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    A=[int(input()) for i in range(N)]+[0]
    ans=0
    for i in range(N):
        if A[i+1]>0 and A[i]>0:
            tmp=min(A[i+1],A[i])
            if tmp==A[i+1]!=A[i] and tmp%2:
                tmp-=1
            ans+=tmp
            A[i+1]-=tmp
            if A[i]-tmp>=2:
                ans+=(A[i]-tmp)//2
        elif A[i]>=2:
            ans+=A[i]//2
    print(ans)
    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    A=[int(input()) for i in range(N)]+[0]
    ans=0
    for i in range(N):
        if A[i+1]>0 and A[i]>0:
            tmp=min(A[i+1],A[i])
            if tmp==A[i+1] and tmp%2:
                tmp-=1
            ans+=tmp
            A[i+1]-=tmp
            if A[i]-tmp>=2:
                ans+=(A[i]-tmp)//2
        elif A[i]>=2:
            ans+=A[i]//2
    print(ans)
    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]
ans = 0
for i in range(N-1):
  dup1 = A[i] // 2
  A[i] -= dup1 * 2
  dup2 = min(A[i], A[i+1])
  A[i+1] -= dup2
  ans += dup1 + dup2
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
import itertools

mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

N = ni()
A = list()
for _ in range(N):
    A.append(ni())
cnt = 0
for i in range(N-1):
    ccnt = (A[i] + A[i+1]) //2
    A[i+1] -= ccnt*2
    cnt += ccnt
print(cnt)

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    A=[int(input()) for i in range(N)]+[0]
    ans=0
    for i in range(N):
        if A[i+1]>0 and A[i]>0:
            tmp=min(A[i+1],A[i])
            ans+=tmp
            A[i+1]-=tmp
            if A[i]-tmp>=2:
                ans+=(A[i]-tmp)//2
        elif A[i]>=2:
            ans+=A[i]//2
    print(ans)
    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n, *a = map(int, open(0).read().split())

ans = prev = 0
for i in a:
        tmp = divmod(i+prev, 2)
        ans += tmp[0]
        if i==0: prev=0
print(ans)

Submission status: Wrong Answer

Solution code:
n, *a = map(int, open(0).read().split())

ans = prev = 0
for i in a:
        ans += i//2
        if i%2:
                ans += prev
                prev ^= 1
        else: prev = 0
print(ans)

Submission status: Wrong Answer

Solution code:
n, *a = map(int, open(0).read().split())

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

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
from itertools import groupby
n = int(stdin.readline().rstrip())
li = [int(stdin.readline().rstrip()) for _ in range(n)]
lin = []
for key, value in groupby(li):
    lin.append(key)
count = 0
point = 0
for i in lin:
    if i == 0:
        point += count//2
        count = 0
    else:
        count += i
point += count//2
print(point)

Submission status: Wrong Answer

Solution code:
N=int(input())
sum=0
A=int(input())
sum+=A//2
a=A%2
for _ in range(N-1):
    A=int(input())
    sum+=A//2
    b=A%2
    m=min(a,b)
    if m>0:
        sum+=m
        b-=m
    a=b
print(sum)

Submission status: Wrong Answer

Solution code:



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

"""
i番目を見ている時に、i+1番目と組にするか考える。
i+1はi+2と組にできるので、残せるなら残す。

"""

ans = 0
for i in range(N):
    if i != N-1:
        tmp = A[i] // 2
        ans += tmp
        A[i] -= tmp*2
        if A[i] != 0:
            tmp = min(A[i], A[i-1])
            ans += tmp
            A[i] -= tmp
            A[i] -= tmp
    else:
        ans += A[i] // 2


print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

ans = 0
List = []
for i in range(N):
    A = int(input())
    ans += A // 2
    A %= 2
    List.append(A)

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

print(ans)

Submission status: Wrong Answer

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

cnt = 0

for i in range(N - 1):
    if T[i] != 0 and T[i + 1] != 0:
        if T[i] >= T[i + 1]:
            cnt += T[i + 1]
            T[i] -= T[i + 1]
            T[i + 1] = 0
        else:
            cnt += T[i]
            T[i + 1] -= T[i]
            T[i] = 0

for t in T:
    cnt += t // 2

print(cnt)

Submission status: Wrong Answer

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

cnt = 0
T = []

for a in A:
    x, y = divmod(a, 2)
    cnt += x
    T.append(y)

for i in range(len(T) - 1):
    if T[i:i + 2] == [1, 1]:
        cnt += 1
        T[i], T[i + 1] = 0, 0

print(cnt)

Submission status: Wrong Answer

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

cnt = 0
T = []

for a in A:
    x, y = divmod(a, 2)
    cnt += x
    T.append(y)

for i in range(len(T) - 1):
    if T[i:i+1] == [1, 1]:
        cnt += 1
        T[i], T[i + 1] = 0, 0

print(cnt)

Submission status: Wrong Answer

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

A.sort()

con = False
ans = 0
for i in range(N):
    if A[i] >=2:
        ans += A[i]//2
        A[i] -= A[i]//2
    
    mm = min(A[i+1],A[i])
    ans += mm
    A[i+1] -= mm
    A[i] -= mm


print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = 0
prev_A = -10
prev_card_num = 0
for i in range(1,N+1):
    A = int(input())
    ans += (prev_card_num + A)//2
    if (prev_card_num+A)%2 == 1:
        prev_card_num = 1
        prev_A = i
    else:
        prev_card_num = 0
        prev_A = i
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = 0
prev_A = -10
prev_card_num = 0
for i in range(1,N+1):
    A = int(input())
    ans += (prev_card_num + A)//2
    if prev_A == i-1 and (prev_card_num+A)%2 == 1:
        prev_card_num = 1
        prev_A = i
    elif prev_A == i-1 and (prev_card_num+A)%2 == 0:
        prev_card_num = 0
    else:
        prev_card_num = 1
        prev_A = i
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = 0
prev_A = -10
prev_card_num = 0
for i in range(1,N+1):
    A = int(input())
    ans += A//2
    if prev_A == i-1 and prev_card_num == 1 and A%2 == 1:
        ans += 1
        prev_card_num = 0
    elif A%2 == 1:
        prev_card_num = 1
        prev_A = i
    else:
        prev_card_num = 0
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = 0
prev_A = -10
prev_card_num = 0
for i in range(1,N+1):
    A = int(input())
    ans += A//2
    if prev_A == i-1 and prev_card_num == 1 and A%2 == 1:
        ans += 1
        prev_card_num = 0
    elif A%2 == 1:
        prev_card_num = 1
        prev_A = i
print(ans)

Submission status: Wrong Answer

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

ans = 0
c = a[0]
for i in range(n - 1):
    b = c
    c = a[i + 1]
    use = b // 2 * 2
    ans += use // 2
    b -= use
    if b and c >= 1:
        ans += 1
        c -= 1
ans += c // 2 * 2

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial, ceil, floor
from collections import defaultdict
import itertools
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, M, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

N, = map(int, input().split())
L = [int(input()) for _ in range(N)]

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(input()) for i in range(n)]
ans=0
for i in range(n):
  ans+=a[i]//2
  a[i]=a[i]%2
if n>=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=[int(input()) for i in range(n)]
ans=0
for i in range(n):
  ans+=a[i]//2
  a[i]=a[i]%2
if n==2:
  if a[0]==1 and a[1]==1:
    ans+=1
elif n>=3:
  for i in range(n-2):
    if a[i]==1 and a[i+1]==1:
      ans+=1
      a[i]=0
      a[i+1]=0
    elif a[i]==1 and a[i+1]==0:
      if a[i+2]==1:
        ans+=1
        a[i]=0
        a[i+2]=0
print(ans)