Problem:


Score : 300 points

Problem Statement

You are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N.
Determine if we can repeat the following operation zero or more times so that the sequences a and b become equal.

Operation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perform the following two actions simultaneously:

Add 2 to a_i.

Add 1 to b_j.

Constraints

1 ≤ N ≤ 10 000

0 ≤ a_i,b_i ≤ 10^9 (1 ≤ i ≤ N)

All input values are integers.

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 .. a_N
b_1 b_2 .. b_N

Output

If we can repeat the operation zero or more times so that the sequences a and b become equal, print Yes; otherwise, print No.

Sample Input 1

3
1 2 3
5 2 2

Sample Output 1

Yes

For example, we can perform three operations as follows to do our job:

First operation: i=1 and j=2. Now we have a = \{3,2,3\}, b = \{5,3,2\}.

Second operation: i=1 and j=2. Now we have a = \{5,2,3\}, b = \{5,4,2\}.

Third operation: i=2 and j=3. Now we have a = \{5,4,3\}, b = \{5,4,3\}.

Sample Input 2

5
3 1 4 1 5
2 7 1 8 2

Sample Output 2

No

Sample Input 3

5
2 7 1 8 2
3 1 4 1 5

Sample Output 3

No



Sample input:
3
1 2 3
5 2 2


Sample output:
Yes

Submission status: Accepted

Solution code:
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

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


# ===CODE===


def main():
    n = ni()
    a = na()
    b = na()

    a_cnt = 0
    b_cnt = 0

    for ai, bi in zip(a, b):
        tmp = bi - ai
        if tmp < 0:
            b_cnt += abs(tmp)
        elif tmp > 0:
            a_cnt += (tmp + 1) // 2
            b_cnt += tmp % 2
        # print(ai, bi, a_cnt, b_cnt)

    print("Yes" if a_cnt >= b_cnt else "No")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

A = list(map(int, input().split()))
B = list(map(int, input().split()))

#print(A)
#print(B)

x=y=0
for i in range(len(A)):
  a, b = A[i], B[i]

  if a<b: x+=(b-a)//2*2
  if a>b: y+=a-b

ans="Yes" if x >= y*2 else "No"
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ab = [0] * N
for i in range(N):
    ab[i] = B[i] - A[i]
m = sum(ab)
ab = sorted(ab, reverse=True)
import math
f, g = 0, 0
for c in ab:
    if c > 0:
        f += math.ceil(c/2)
    elif c < 0:
        g += -c
if max(f, g) <= m:
    result = "Yes"
else:
    result = "No"
print(result)

Submission status: Accepted

Solution code:
n=int(input())

a=[int(_) for _ in input().split()]
b=[int(_) for _ in input().split()]

m=sum(b)-sum(a)
l=0
for i in range(n):
  if a[i]<b[i]:
    l+= (b[i]-a[i]+1)//2
    
if l>m:
  print("No")
else:
  print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

cnt=0
for i in range(n):
  x=a[i]
  y=b[i]
  if x>y:
    cnt-=x-y
  elif x<y:
    cnt+=(y-x)//2

print('Yes' if cnt>=0 else 'No')

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

cnt=0
margin=0
for i in range(n):
  x=a[i]
  y=b[i]
  if x>y:
    cnt+=x-y
  elif x<y:
    margin+=(y-x)//2

print('Yes' if margin>=cnt else 'No')

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ca = cb = 0
for i in range(n):
    if a[i] > b[i]:
        ca += a[i] - b[i]
    elif a[i] < b[i]:
        cb += (b[i] - a[i])//2
if cb >= ca:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    n = II()
    aa = MII()
    bb = MII()
    ra = rb = 0
    for a,b in zip(aa,bb):
        if a>b: ra += a-b
        if b>a: rb += (b-a)//2
    if rb >= ra: print('Yes')
    else: print('No')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    n = II()
    aa = MII()
    bb = MII()
    dn = sum(bb) - sum(aa)
    if dn < 0:
        print('No')
        return None
    cnta = cntb = 0
    for a,b in zip(aa,bb):
        if a>b: cntb += a-b
        else: cnta += (b-a+1)//2
    if cnta <= dn and cntb <= dn:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
pdiff = 0
ndiff = []
for i, j in zip(a, b):
    if i-j>0:
        pdiff += i-j
    elif i-j<0:
        ndiff.append(j-i)

while ndiff:
    tmp = ndiff.pop()
    pdiff -= tmp//2
if pdiff<=0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
# 大きい順 or 小さい順に揃えていく
ds = [a-b for a,b in zip(As,Bs)]
if sum(ds) > 0:
    print("No")
    exit()
cnt = 0
cnts = []
for d in ds:
    # print(d)
    if d < 0:
        c = -(d//2)
        cnt += c
        d += c * 2
    cnts.append(d)
if cnt >= sum(cnts):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

sum_a = sum(a)
sum_b = sum(b)
if sum_a <= sum_b:
    cnt = 0
    for i in range(n):
        if a[i] > b[i]:
            cnt += a[i] - b[i]
        elif a[i] < b[i]:
            cnt -= (b[i] - a[i]) // 2
    if cnt <= 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
n=int(input())
 
a=list(map(int,input().split()))
b=list(map(int,input().split()))
 
num=sum(b)-sum(a)
if num<0:
    print("No")
    exit()
 
need=0
for i in range(n):
    aa=a[i]
    bb=b[i]
    if aa>bb:
        need+=aa-bb
    elif aa<bb:
        need-=(bb-aa)//2
 
if need<=0:print("Yes")
else:print("No")

Submission status: Accepted

Solution code:
def petrozavodsk001_b():
    _ = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    act = sum(B) - sum(A)
    if act < 0:
        print('No')
        return

    addA, addB = 0, 0
    for a, b in zip(A, B):
        if a > b: addB += a - b
        else: addA += (b - a + 1) // 2

    if addA <= act and addB <= act:
        print('Yes')
    else:
        print('No')

petrozavodsk001_b()

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

operation = sum(B) - sum(A)

cntp = 0
cntn = 0
for a, b in zip(A, B):
    c = b - a
    if c > 0:
        cntp += c
        if c % 2 != 0:
            operation -= 1
    elif c < 0:
        cntn += -c


if operation >= cntn:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
cou = sum(b) - sum(a)
ac = 0
bc = 0
for i in range(n):
    if a[i] < b[i]:
        if (b[i] - a[i]) % 2 == 0:
            ac += (b[i]-a[i])//2
        elif (b[i] - a[i]) % 2 == 1:
            ac += (b[i]-a[i])//2 + 1
            bc += 1
    elif a[i] > b[i]:
        bc += a[i]-b[i]
if ac > cou or bc > cou:
    print("No")
else:
    if cou - bc == (cou-ac)*2:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
#from collections import deque,defaultdict
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 = inl()
b = inl()
ia = ib = 0
for i in range(n):
    if a[i]>b[i]:
        ib += a[i]-b[i]
    elif a[i]<b[i]:
        d = b[i]-a[i]
        if d%2==0:
            ia += d//2
        else:
            ia += (d+1)//2
            ib += 1
print('Yes' if ia>=ib else 'No')

Submission status: Accepted

Solution code:
n=int(input())

a=list(map(int,input().split()))
b=list(map(int,input().split()))

num=sum(b)-sum(a)
if num<0:
    print("No")
    exit()

need=0
for i in range(n):
    aa=a[i]
    bb=b[i]
    if aa>bb:
        need+=aa-bb
    elif aa<bb:
        need-=(bb-aa)//2

if need<=0:print("Yes")
else:print("No")

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
S=sum(b)-sum(a)
if S<0:print("No")
else:
    cnt=0
    for i in range(n):
        cnt+=max((b[i]-a[i]+1)//2,0)
    if cnt<=S:print('Yes')
    else:print("No")

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/apc001/tasks/apc001_b

n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
t = sum(b) - sum(a)
pos = 0
neg = 0
for i in range(n):
    d = a[i] - b[i]
    if d > 0:
        pos += d
    elif d < 0:
        neg += -1 * d // 2
if pos <= neg:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=list(map(int,input().split()))
    B=list(map(int,input().split()))
    Da=[-(-(b-a)//2) for a,b in zip(A,B) if a<b]
    Db=[a-b for a,b in zip(A,B) if a>b ]
    if sum(B)-sum(A)>=max(sum(Da),sum(Db)):print("Yes")
    else:print("No")

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
da = 0
db = 0
for i in range(n):
    if a[i] > b[i]:
        db += a[i]-b[i]
    else:
        da += (b[i]-a[i])//2
if db > da:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

c = max(0, sum(B) - sum(A))
ca = 0
cb = 0

for a, b in zip(A, B):
    if a < b:
        ca += (b - a + 1) // 2
        cb += (b - a) % 2
    if a > b:
        cb += a - b

if c < max(ca, cb):
    print('No')
else:
    print('Yes')

Submission status: Accepted

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, groupby, combinations_with_replacement
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
import numpy as np
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 = LIST()
b = LIST()

tmp1 = 0
tmp2 = 0
for i, j in zip(a, b):
	if i > j:
		tmp1 += i-j
	elif j > i:
		tmp2 += (j-i)//2

if tmp2 >= tmp1:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

SA = sum(A)
SB = sum(B)

cnt_a, cnt_b = 0, 0
for i in range(N):
  if A[i] <= B[i]:
    cnt_a += (B[i] - A[i] + 1)//2
  else:
    cnt_b += A[i] - B[i]

if SB - SA >= max(cnt_a, cnt_b):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
su=0
c=[]
for i in range(n):
    x=a[i]-b[i]
    if x>=0:
        su += x
    else:
        c.append(-x)
cap=0
for i in range(len(c)):
    cap += c[i]//2
if cap>=su:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

countA,countB = 0,0

for i in range(N):
  if A[i] <= B[i]:
    countA += (B[i]-A[i])//2
  else:
    countB += A[i]-B[i]
if countA >= countB:
  ans = "Yes"
else:
  ans = "No"

print(ans)

Submission status: Accepted

Solution code:
def main():
  n=int(input())
  a=list(map(int,input().split()))
  b=list(map(int,input().split()))
  c=[a[i]-b[i] for i in range(n)]
  c0=sum([ci for ci in c if ci>0])
  c1=sum([-2*((ci+2-1)//2) for ci in c if ci<0])
  print('Yes' if c1>=2*c0 else 'No')
if __name__=='__main__':
  main()

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    cnt = 0
    for i in range(n):
        if a[i] < b[i]:
            cnt += (b[i]-a[i])//2
        else:
            cnt += b[i]-a[i]
    if cnt >= 0:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
bigger_a = 0
bigeer_b = 0
for a, b in zip(A, B):
    if a > b:
        bigger_a += a - b
    if b > a:
        bigeer_b += (b - a) // 2
ans = 'Yes' if bigeer_b >= bigger_a else 'No'
print(ans)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
a = list(map(int, readline().split()))
b = list(map(int, read().split()))
cnt = 0
for aa, bb in zip(a, b):
    v = bb - aa
    if bb > aa:
        v //= 2
    cnt += v
if cnt >= 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N=int(input())

A=list(map(int, input().split()))
B=list(map(int, input().split()))
K=sum(B)-sum(A)
if K<0:
    print("No")
    exit()

#合計値が追い越さないように　sum(B)-sum(A)回までしかできない

anum=0
bnum=0
for i in range(N):
    a=A[i]
    b=B[i]
    if a>b:
        bnum+=a-b
    elif b>a:
        if (b-a)%2==0:
            anum+=(b-a)//2
        else:
            anum+=(b-a)//2+1
            bnum+=1

if K>=max(anum,bnum):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import math

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

sum_a = sum(a)
sum_b = sum(b)
num_b = 0
num_a = 0
for i in range(n):
    if a[i] > b[i]:
        num_b += a[i] - b[i]
    else:
        num_a += math.ceil((b[i]-a[i])/2)

if sum_b-sum_a >= num_b and sum_b-sum_a >= num_a:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
k = sum(B)-sum(A)

if k < 0:
    print('No')
else:
    cnt_a = cnt_b = 0
    for a, b in zip(A, B):
        if a < b:
            x, y = divmod((b-a), 2)
            cnt_a += x+y
            cnt_b += y
        elif b < a:
            cnt_b += b-a
    if max(cnt_a, cnt_b) <= k:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
k = sum(B)-sum(A)


if k < 0:
    print('No')
else:
    cnt_a = 0
    cnt_b = 0
    for a, b in zip(A, B):
        if a < b:
            x, y = divmod((b-a), 2)
            cnt_a += x+y
            cnt_b += y
        elif b < a:
            cnt_b += a-b
    if max(cnt_a, cnt_b) <= k:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

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

n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
cnt = sum(b) - sum(a)
diff1 = [] # a > b
diff2 = [] # b > a
for i, j in zip(a, b):
    if i > j:
        diff1.append(i - j)
    elif j > i:
        diff2.append(j - i)

if cnt < sum(diff1):
    print("No")
    sys.exit()
else:
    cnt -= sum(diff1)

a_add = cnt + sum(diff1) # 2を足す
b_add = cnt # 1を足す

c = []
for i in diff2:
    if i % 2 == 0:
        a_add -= i//2
    else:
        c.append(1)
        a_add -= (i - 1)//2
a_add -= sum(c)
b_add -= sum(c)
if a_add*2 == b_add and a_add >= 0 and b_add >= 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
def main():
    input = sys.stdin.readline
    N=int(input())
    *A,=map(int, input().split())
    *B,=map(int, input().split())

    opa=opb=0
    for a,b in zip(A,B):
        if a>=b:
            opb+=a-b
        else:
            if (b-a)&1==0:
                opa+=(b-a)//2
            else:
                opa+=(b-a)//2 + 1
                opb+=1

    print('Yes' if opa>=opb else 'No')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
def main():
    input = sys.stdin.readline
    N=int(input())
    *A,=map(int, input().split())
    *B,=map(int, input().split())

    asum=sum(A)
    bsum=sum(B)
    asmall=0
    bsmall=0
    for a,b in zip(A,B):
        asmall+=(max(0, b-a)+1)//2
        bsmall+=max(0, a-b)
    t=bsum-asum
    print('Yes' if t>=max(asmall,bsmall) else 'No')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
x = 0
y = 0
for i in range(N):
    if A[i]>B[i]:
        x += A[i]-B[i]
    else:
        y += (B[i]-A[i])//2
if y>=x:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

cnt = 0
for i in range(n):
  if a[i] <= b[i]:
    cnt += (b[i]-a[i])//2
    continue
  else:
    cnt -= a[i]-b[i]

if cnt >= 0: print("Yes")
else: print("No")

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
sum_a=sum(a)
sum_b=sum(b)
a_cnt,b_cnt=0,0
for aa,bb in zip(a,b):
    if aa>bb:
        a_cnt+=aa-bb
    elif aa<bb:
        b_cnt+=(bb-aa)//2
if a_cnt<=b_cnt:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
b = inpl()
res = 0
for i in range(n):
    if a[i] > b[i]:
        res += b[i] - a[i]
    elif b[i] - a[i]:
        res += (b[i] - a[i])//2
print('Yes' if res >= 0 else 'No')

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

K = sum(B) - sum(A)

cntA = 0
for i in range(N):
    a, b = A[i], B[i]
    d = b - a
    if d > 0:
        d = -(-d // 2)
        cntA += d
        A[i] += d * 2

cntB = 0
for i in range(N):
    a, b = A[i], B[i]
    d = a - b
    if d > 0:
        cntB += d
        B[i] += d

if max(cntA, cntB) > K:
    print('No')
    exit()

dA = K - cntA
dB = K - cntB

print('Yes' if dA * 2 == dB else 'No')

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ret = [0] * n
for i in range(n):
    ret[i] = b[i] - a[i]
ret = sorted(ret)

cnt = 0
for i, val in enumerate(ret):
    if val < 0:
        cnt += abs(val)
        ret[i] = 0
    elif val % 2 == 1:
        cnt += 1
        ret[i] += 1

for i, val in enumerate(ret):
    cnt -= val // 2
if cnt <= 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))



count = 0
for i in range(N):
    if A[i] <= B[i]:
        count += (B[i] - A[i]) // 2
        continue
    else:
        count -= A[i] - B[i]


if count >= 0:
    print ('Yes')
else:
    print ('No')

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
sa,sb = sum(A),sum(B)
if sa > sb:
    print('No')
    exit()

x = y = 0
for a,b in zip(A,B):
    if a < b:
        x += (b-a+1)//2
        y += (b-a)%2
    elif a > b:
        y += a-b

if x>sb-sa or y>sb-sa:
    print('No')
else:
    print('Yes' if x>=y else 'No')

Submission status: Accepted

Solution code:

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

cnt = 0
for a, b in zip(A, B):
    if a > b:
        cnt -= a - b
    if a < b:
        cnt += (b - a) // 2

if cnt < 0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
a = list( map(int, input().split()))
b = list( map(int, input().split()))

sa = sum(a)
sb = sum(b)

al = sb-sa

if al<0:
    print('No')
    exit()

doub = 0
sing = 0

for i in range(n):
    diff = b[i]-a[i]
    if diff > 0:
        doub += -(-diff//2)
        sing += diff%2
    if diff < 0:
        sing += -diff

dnokori = al - doub
snokori = al - sing

if dnokori < 0 or snokori<0:
    print('No')
    exit()

if dnokori==0 and snokori==0:
    print('Yes')
    exit()

if dnokori==0:
    print('No')
    exit()

if snokori/dnokori == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    cnt = 0
    for i in range(n):
        if B[i] < A[i]:
            cnt += A[i] - B[i]
            B[i] = A[i]

    for i in range(n):
        if B[i] > A[i]:
            cnt -= (B[i] - A[i]) // 2

    if cnt <= 0:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

x=sum(b)-sum(a)

if x<0:
    print("No")
elif x==0:
    if a==b:
        print("Yes")
    else:
        print("No")
else:
    if x%2==0 and sum(a)%2!=sum(b)%2:
        print("No")
    elif x%2==1 and sum(a)%2==sum(b)%2:
        print("No")
    else:
        cnt=0
        for i in range(n):
            if a[i]<b[i]:
                cnt+=(b[i]-a[i]+1)//2
        if cnt<=x:
            print("Yes")
        else:
            print("No")

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
bigger_a = bigger_b = 0
for a_, b_ in zip(a, b):
    if a_ > b_: bigger_a += a_ - b_
    if b_ > a_: bigger_b += (b_ - a_) // 2
if bigger_b >= bigger_a: print("Yes")
else: print("No")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))

import math
n1 = sum([max(0, a-b)  for a, b in zip(A, B)])
n2 = sum([max(0, int(math.floor((b-a)/2))) for a, b in zip(A, B)])

if n2 >= n1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import numpy as np
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
d,e=0,0
for i in range(n):
  c=a[i]-b[i]
  if c>0:
    d+=c
  elif c%2==0:
    e+=-c
  else:
    e+=-c-1
print('Yes' if 2*d<=e else 'No')

Submission status: Accepted

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat[i])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N = I()
    a = LI()
    b = LI()

    plus = 0
    minus = 0
    for i in range(N):
        if a[i] > b[i]:
            plus += a[i] - b[i]
        else:
            minus += (b[i] - a[i]) // 2

    # print(plus, minus)
    print(yn[plus <= minus])


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
ai = [int(i) for i in input().split()]
bi = [int(i) for i in input().split()]

sita = 0
ue = 0

for i in range(n):
    if ai[i] >= bi[i]:
        sita += ai[i] - bi[i]
    else:
        ue += (bi[i] - ai[i]+1) // 2

#print(sum(bi),sum(ai),ue,sita)
        
if sum(bi) - sum(ai) - max(ue,sita) >= 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())
a_li = list(map(int,input().split()))
b_li = list(map(int,input().split()))

kaisu = 0
ukeire = 0
for a,b in zip(a_li,b_li):
    if a>b:
        kaisu += a-b
    elif a<b:
        ukeire += (b-a)//2
if ukeire >= kaisu:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cnt=[0]*n
for i in range(n):
    cnt[i]=b[i]-a[i]
cnt.sort()
p=n-1
for i in range(n):
    while cnt[i]<0:
        if cnt[p]<=1:
            print("No")
            exit()
        elif cnt[p]-abs(cnt[i])*2>=2:
            cnt[p]-=abs(cnt[i])*2
            cnt[i]=0
        elif cnt[p]-abs(cnt[i])*2>=0:
            cnt[p]-abs(cnt[i])*2
            cnt[i]=0
            p-=1
        else:
            x=cnt[p]//2
            cnt[i]+=x
            p-=1
print("Yes")

Submission status: Accepted

Solution code:
N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
anum=0
bnum=0
equalflag=0
for i in range(N):
    if a[i]>b[i]:   #bを嵩上げしないと
        bnum=bnum+(a[i]-b[i])
    elif a[i]<b[i]:#aを嵩上げしないと
        if (b[i]-a[i])%2==0:    #差が2nならaをn回嵩上げ
            anum=anum+(b[i]-a[i])//2
        else:                   #差が2n+1ならbを一回嵩上げしてからaをn+1回嵩上げ
            bnum=bnum+1
            anum=anum+((b[i]+1)-a[i])//2
if N!=1:
    if anum>=bnum:
        print("Yes")
    else:
        print("No")
else:
    if anum==bnum:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 29 21:14:35 2020
"""

import sys
import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

N = int(input())
#X, Y = map(int,input().split())
a = np.array(list(map(int,input().split())))
b = np.array(list(map(int,input().split())))

c = b - a

ok = np.sum(c[c > 0]//2)
ng = np.sum(-c[c < 0])

if ok >= ng:
    ans = 'Yes'
else:
    ans = 'No'
print(ans)

Submission status: Accepted

Solution code:
def main():
    import sys
    import time
    input = sys.stdin.readline
    N = int(input())
    A = [int(x) for x in input().strip().split()]
    B = [int(x) for x in input().strip().split()]
    cnt = 0
    for a, b in zip(A, B):
        a_b = a - b
        if a_b > 0:
            cnt += a_b
        elif a_b < 0:
            cnt -= -a_b // 2
    
    if cnt <= 0:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

assign_plus = 0
minus = 0

for i in range(N):
    assign_plus += max(0, (b[i]-a[i])//2)
    minus += max(0, a[i]-b[i])

if assign_plus >= minus:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n=int(input())
a,b=[list(map(int,input().split())) for i in range(2)]
if sum(a) >sum(b):print("No")
elif sum(a)==sum(b):

    for x,c in zip(a,b):
        if x!=c:print("No");exit()
    print("Yes")
else:
    cnt=sum(b)-sum(a)
    v=cnt
    for x,y in zip(a,b):
        if x>=y:v-=(x-y)
        else:
            v-=(x+y)%2
            cnt-=(y-x+(x+y)%2)//2
    print("Yes") if cnt*2==v and cnt>=0 and v>=0 else print("No")

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

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

if sum(b) - sum(a) < 0:
    print('No')        
elif ope <= sum(b) - sum(a):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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


def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    biggerA = 0
    biggerB = 0
    task = 0
    for i in range(N):
        # A[i]>B[i]なる全てのB[i]を埋めてA[i]<=B[i]とできれば勝ち
        if A[i] > B[i]:  # B[i]をcnt分埋めるというタスクがある
            task += A[i] - B[i]
        if A[i] < B[i]:  # B[i]が優っている箇所でA[i]を埋めてタスクを解消
            task -= (B[i] - A[i]) // 2

    if task <= 0:
        print('Yes')
    else:
        print('No')


resolve()

Submission status: Accepted

Solution code:
import sys
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

asum = sum(a)
bsum = sum(b)

if bsum - asum < 0:
    print("No")
    sys.exit()
    
kai = 0
for i in range(n):
    if b[i] > a[i]:
        kai += (b[i]-a[i]+1) // 2
        
if kai > bsum - asum:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    _ = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    cnt = 0
    for a, b in zip(A, B):
        if a < b:
            cnt += (b - a) // 2
        else:
            cnt -= a - b

    if cnt < 0:
        print("No")
    else:
        print("Yes")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
a = list(map(int, readline().split()))
b = list(map(int, readline().split()))
cnt = 0
for i in range(n):
    cnt += max(0, (b[i] - a[i] + 1) // 2)
if sum(b) - sum(a) >= cnt:
    print('Yes')
else:
    print('No')