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:
N = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

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

if x <= y:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

def f():
    req_a = 0
    req_b = 0
    for a,b in zip(A, B):
        if a > b:
            req_b += (a - b)
        else:
            if (b - a) & 1:
                req_a += (b - a) // 2 + 1
                req_b += 1
            else:
                req_a += (b - a) // 2
    return req_a >= req_b

print("Yes" if f() else "No")

Submission status: Accepted

Solution code:
N = int(raw_input())
A = map(int, raw_input().split())
B = map(int, raw_input().split())
cae = 0
cao = 0
cb = 0
for i in range(N):
  if A[i]>B[i]:
    cb += A[i]-B[i]
  elif A[i]<B[i]:
    ca = B[i]-A[i]
    cae += ca // 2
    cao += ca % 2
print "Yes" if cae>=cb else "No"

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):
    a = A[i]
    b = B[i]
    if a > b:
        y += a - b
    elif a < b:
        diff = b - a
        if diff % 2 == 0:
            x += diff // 2
        else:
            x += diff // 2 + 1
            y += 1
#print(x, y)
if x >= y:
    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()))
l = sum(B)-sum(A)
c = 0
for k in range(N):
    if A[k]>B[k]:
        c -= A[k]-B[k]
    elif A[k]<B[k]:
        c += (B[k]-A[k])//2

print("Yes" if 0<=c else "No")

Submission status: Accepted

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

Submission status: Accepted

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

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

    dif_sum = sum(b) - sum(a)
    if dif_sum == 0 and p == 0 and m == 0:
        print("Yes")
    elif dif_sum <= 0:
        print("No")
    elif dif_sum >= m and dif_sum >= p:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def b_two_arrays(N, A, B):
    import math
    operation_times = 0
    for a, b in zip(A, B):
        if a < b:
            operation_times += math.ceil((b - a) / 2)
    ans = 'Yes' if operation_times <= (sum(B) - sum(A)) else 'No'
    return ans

N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
print(b_two_arrays(N, A, B))

Submission status: Accepted

Solution code:
n = int(input())

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

count = 0
count_b = 0
for i in range(len(a)):
    if a[i] <= b[i]:
        count += -(-(b[i]-a[i])//2)
        if (b[i]-a[i])%2 == 1:
            count_b += 1
    else:
        count_b += (a[i]-b[i])
if count >= count_b:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())
a = [int(i) for i in input().split()]
A = sum(a)
b = [int(i) for i in input().split()]
B = sum(b)
def cost(n):
    if n == 0:
        return [0, 0]
    elif n < 0:
        return [0, -n]
    elif n > 0 and n % 2 == 0:
        return [n//2, 0]
    else:
        return [(n+1)//2, 1]

K = B - A
PC = 0
MC = 0
for i in range(N):
    c = cost(b[i] - a[i])
    PC += c[0]
    MC += c[1]
if PC <= K and MC <= K and ((K-PC)*2 == (K-MC)):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(raw_input())
a = map(int, raw_input().split())
b = map(int, raw_input().split())
d = sum(b) - sum(a)
if d < 0:
    print "No"
elif all([i==j for i,j in zip(a,b)]):
    print "Yes"
else:
    ct = 0
    for i,j in zip(a,b):
        if i < j:
            ct += (j-i+1) / 2
    if ct <= d:
        print "Yes"
    else:
        print "No"

Submission status: Accepted

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
num,A,B = 0,sum(a),sum(b)
for i in range(n): num+=max(0,((b[i]-a[i])+(b[i]-a[i])%2)//2)
if num>B-A: print("No")
else: print("Yes")

Submission status: Accepted

Solution code:
import sys
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=[]
m2=0
p1=0
m1=0
for i in range(n):
  c.append(b[i]-a[i])
s=sum(c)
cou=0
for i in range(n):
  if(c[i]<0):
    cou+=0
  elif(c[i]>0):
    cou+=(c[i])//2+(c[i])%2
if(cou<=s):print("Yes")
else:print("No")

Submission status: Accepted

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

diff = [bi - ai for (ai, bi) in zip(a, b)]
if sum(diff) < 0:
    print('No')
    exit()

sum_of_2minus = -sum(filter(lambda x: x < 0, diff))
capable_2x = sum(map(lambda y: int(y / 2), filter(lambda x: x > 1, diff)))
if capable_2x < sum_of_2minus:
    print('No')
    exit()

print('Yes')

Submission status: Accepted

Solution code:
import math
from queue import PriorityQueue


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

A_sum = sum(A)
B_sum = sum(B)
diff = B_sum - A_sum
if diff < 0:
    print("No")
    exit()

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

if cnt > diff:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
import math

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

total_manipulation =  sum(B) - sum(A)

manipulation_A = 0
manipulation_B = 0

for i in range(N):
    if A[i] < B[i]:
        manipulation_A += math.ceil((B[i] - A[i]) / 2)
        manipulation_B += (B[i] - A[i]) % 2
    elif A[i] > B[i]:
        manipulation_B += A[i] - B[i]

if total_manipulation - max(manipulation_A, manipulation_B) >= 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()))
p=0
for i in range(n):
    if a[i]<b[i]:
        p+=(b[i]-a[i])//2
    elif b[i]<a[i]:
        p-=(a[i]-b[i])
if p>=0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

c = 0
for i in range(n):
    ai = a[i]
    bi = b[i]
    if ai < bi:
        c += (bi-ai)//2
    else:
        c -= (ai-bi)
print('Yes' if c >= 0 else 'No')

Submission status: Accepted

Solution code:


def func():
    n=int(input())
    A=[int(s) for s in input().split()]
    B=[int(s) for s in input().split()]
    two=0
    one=0
    for i in range(0,len(A)) :
        if A[i] > B[i] : 
            one+=A[i]-B[i]
        elif A[i] < B[i] :
            two+=(B[i]-A[i])//2
            one+=(B[i]-A[i])%2
            two+=(B[i]-A[i])%2
    if two-one >= 0 :
        print("Yes")
    else :
        print("No")


func()

Submission status: Accepted

Solution code:

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

sumA = 0
sumB = 0
sumAB = 0

for i in range(n):
    sumA += A[i]
    sumB += B[i]

for i in range(n):
    if A[i] < B[i]:
        sumAB += int((B[i] - A[i]) / 2 + 0.5)

if sumAB <= sumB - sumA:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from math import ceil
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = 0
for x, y in zip(a, b):
    if y > x:
        c += ceil((y-x)/2)

if sum(b)-sum(a)>=0 and sum(b)-sum(a)>=c:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

# 3 7 4 7 5
# 3 7 3 8 5

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if a == b:
    print("Yes")
elif sum(a) >= sum(b):
    print("No")
else:
    aa = 0
    bb = 0
    for i in range(N):
        if a[i]-b[i] > 0:
            bb += a[i]-b[i]
        elif b[i]-a[i] > 0:
            aa += (b[i]-a[i])//2
    if aa >= bb:
        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()))

#
#op = sum(B) - sum(A)
#if op<0:
#    print('No')

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

#
if b<=a:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())
numbersA = input().split()
numbersB = input().split()
diff = []
plusTotal = 0
minousTotal = 0

for i in range(0,n):
	diff.append((int(numbersB[i]) - int(numbersA[i])))
	if diff[i] < 0:
		minousTotal += diff[i]
	else:
		plusTotal += diff[i] // 2



if plusTotal >= abs(minousTotal):
	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()))
a = a.copy()
b = b.copy()
sum_c = 0
for i in range(n):
    if (a[i] - b[i]) < 0:
        sum_c += int(((b[i] - a[i]) / 2 ) + 0.5)
sum_a = 0
sum_b = 0
for i in range(n):
    sum_a += a.pop(0)
    sum_b += b.pop(0)
if sum_c <= (sum_b - sum_a):
    print ('Yes')
else:
    print ('No')

Submission status: Accepted

Solution code:
N = input()
A = map(int, raw_input().split())
B = map(int, raw_input().split())
x = 0

for a, b in zip(A, B):
    if a >= b:
        x -= a - b
    else:
        x += (b - a) / 2

print 'Yes' if x >= 0 else "No"

Submission status: Accepted

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

if a==b:
	print "Yes"
	quit()

try_cnt=sum(b)-sum(a)

C={}
C[1]=try_cnt
C[2]=try_cnt

for i,j in zip(a,b):
	if i<j:
		C[2]-=(j+1-i)/2
		C[1]+=(j-i)%2
	if i>j:
		C[1]-=(i-j)


if C[1]>=0 and C[2]>=0:
	print "Yes"
else:
	print "No"

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
import math
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    factorA = []
    factorB = []
    for index in range(n):
        if a[index] > b[index]:
            factorB.append(a[index]-b[index])
        elif a[index] < b[index]:
            factorA.append((b[index]-a[index])//2)
        else:
            pass
    else:
        if sum(factorA) >= sum(factorB):
            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()))
tot = 0
for i in range(0, n):
  if a[i] < b[i]:
    tot += (b[i] - a[i]) // 2
  else:
    tot -= a[i] - b[i]
print ("Yes" if tot >= 0 else "No")

Submission status: Accepted

Solution code:
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
p = sum(P)
q = sum(Q)
if P == Q:
    print("Yes")
else:
    m = 0
    l = 0
    for i in range(N):
        if Q[i] - P[i] > 0:
            if (Q[i] - P[i]) % 2 == 1:
                #p += (P[i] - Q[i]) * 2
                m += (Q[i] - P[i] + 1) // 2
                l += 1
            else:
                m += (Q[i] - P[i]) // 2
        elif Q[i] - P[i] < 0:
            #q += (Q[i] - P[i])
            l += (P[i] - Q[i])
    if m >= l:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
import sys
import math

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

d = [ y - x for x, y in zip(A, B)]

q = [ x // 2 for x in d if x > 0]
r = [ -x for x in d if x < 0]

if sum(q) >= sum(r):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ds = [b[i] - a[i] for i in range(N)]
p = sum(x // 2 for x in ds if x > 0)
m = sum(-x for x in ds if x < 0)
print(('No', 'Yes')[m <= p])

Submission status: Accepted

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

    b_minus_a = [tmp_b - tmp_a for tmp_a, tmp_b in zip(a, b)]

    if 2 * -sum([_ for _ in b_minus_a if _ < 0]) <= sum([_ - 1 for _ in b_minus_a if _ > 1 and _ % 2 == 1]) + sum(
            [_ for _ in b_minus_a if _ > 1 and _ % 2 == 0]):
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
need = 0
can = 0
for i in range(n):
    if a[i] > b[i]:
        need += a[i] - b[i]
    else:
        can += (b[i] - a[i]) // 2
if need <= can:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

    count = sum(b) - sum(a)
    if count < 0: return print('No')
    if a == b: return print('Yes')

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

    if Amove > Bmove:
        return print('No')
    else:
        return print('Yes')


# main()
after_exp()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = LI()
    b = LI()
    t = 0
    for c,d in zip(a,b):
        s = c - d
        if s == 0:
            continue
        if s < 0:
            s += s%2
            t += s
        else:
            t += s * 2
    if t<=0:
        return 'Yes'

    return 'No'


print(main())

Submission status: Accepted

Solution code:
import sys
if __name__ == "__main__":
    N = int(input())
    A = list(map(int, (input().split(' '))))
    B = list(map(int, (input().split(' '))))

    move = sum(B) - sum(A)
    # A行目が大きい場合は、B行目は+１ずつしかできないので追い越せない。
    if move < 0:
        print('No')
        sys.exit()
    Amove = 0
    Bmove = 0
    # 3 4 2
    # 5 3 4
    for i in range(N):
        # A[i] = 4, B[i] = 3 -> Amove = 1
        if A[i] > B[i]:
            Amove += A[i] - B[i]
        # A[i] = 3, B[i] = 5 -> Bmove = 1
        # A[i] = 2, B[i] = 4 -> Bmove = 1
        elif A[i] < B[i]:
            Bmove += (B[i] - A[i]) // 2
    # Amove = 1, Bmove = 1
    if Amove > Bmove:
        print('No')
    else:
        print('Yes')

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    B = tuple(map(int, input().split()))

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

    if la > lb:
        print('No')
    else:
        print('Yes')

main()

Submission status: Accepted

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

N = int(input())
A = inpl()
B = inpl()

C = 0
D = 0

for a, b in zip(A, B):
    if b - a > 0:
        C += (b-a) - ((b-a)%2)
    else:
        D += (a-b)

if C >= 2*D:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import math
import itertools
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque


# d = defaultdict(lambda: 0)
# setrecursionlimit(10**7)
# inf = float("inf")


##### stdin ####
def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_IL(): return LM(int,stdin)

##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))



##### main #####
def main():
	n = I()
	x = 0; y = 0
	
	for a,b in zip(LI(),LI()):
		if a > b:
			x += a-b
		else:
			y += (b-a)//2

	print('Yes' if y >= x else "No")

if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
from math import ceil

N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

suma = sumb = num = 0
for i in range(N):
    suma += A[i]
    sumb += B[i]
    if A[i] < B[i]:
        num += ceil((B[i] - A[i]) / 2)

if A == B:
    print("Yes")
else:
    if suma >= sumb:
        print("No")
    else:
        if num > sumb - suma:
            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 = []
for i in range(n):
    c.append(a[i] - b[i])
for i in range(n):
    if c[i] < 0 and c[i] % 2 == 1:
        c[i] = 2 * (c[i] // 2 + 1)
d = 0
for i in range(n):
    if c[i] < 0:
        d = d - c[i]//2
e = 0
for i in range(n):
    if c[i] > 0:
        e = e + c[i]
f = max(d, e)
g = 0
for i in range(n):
    g = g - c[i]
if f > g:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

sub = sorted(b[i] - a[i] for i in range(N))
odd = len([x for x in sub if x > 0 and x % 2 == 1])
plus = sum(x for x in sub if x > 0)
minus = sum(x for x in sub if x < 0)
print(('No', 'Yes')[plus + minus * 2 >= odd])

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
minus = 0
plus = 0
for i in range(n):
	if a[i]<b[i]:
		plus += (b[i]-a[i])//2
	else:
		minus += a[i]-b[i]
if plus - minus >= 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()))
res=0
for i in range(len(a)):
  tmp=a[i]-b[i]
  if tmp<0:
    tmp+=tmp%2
    tmp=tmp/2
  res+=tmp
if res>0:
  print('No')
else:
  print('Yes')

Submission status: Accepted

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

import numpy as np

n = int(raw_input())
a = map(int,raw_input().split())
b = map(int,raw_input().split())

a_sum = sum(a)
b_sum = sum(b)

x = b_sum-a_sum

a_over = 0
b_over = 0

for i in range(n):
    check = b[i] - a[i]
    if check > 0:
        b_over += check / 2 + check % 2
    else:
        a_over -= check

#print a_over
#print b_over

if a_over <= x and b_over <= x:
    ans = "Yes"
else:
    ans = "No"

print ans

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
p, q = 0, 0
for i in range(n):
    if a[i] > b[i]:
        p += a[i] - b[i]
    elif a[i] < b[i]:
        q += (b[i] - a[i]) // 2

if p <= q:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

i = 0
asum = 0
bsum = 0
for i in range(N):
    asum += a[i]
    bsum += b[i]

c = True
j = 0
if asum > bsum:
    print("No")
    c = False
elif asum == bsum:
    for j in range(N):
        if a[j] != b[j]:
            print("No")
            c = False
            break
    if c:
        print("Yes")
        c = False
else:
    k = 0
    Da = 0
    Db = 0
    d = bsum - asum 
    while Da <= d and Db <= d:
        dab = 0
        if a[k] < b[k]:
            dab = b[k] - a[k]
            if dab // 2 == 0:
                Da += 1
                a[k] += 2
            else:
                Da += dab // 2
                a[k] += (dab // 2) * 2 
        elif a[k] == b[k]:
            k += 1
        else:
            dab = a[k] - b[k]
            Db += dab
            b[k] += dab
        if k == N:
            break
if c:
    for j in range(N):
        if a[j] != b[j]:
            print("No")
            c = False
            break
    if c:
        if (d - Da) * 2 == (d - Db) * 1:
            print("Yes")
        else:
            print("No")

Submission status: Accepted

Solution code:
N=int(input())
A=[int(i) for i in input().split()]
B=[int(j) for j in input().split()]
a=sum(A)
b=sum(B)
res=b-a
cnt=0
s=0
t=0

for i in range(N):
  if A[i]%2==0:
    s+=1
  if B[i]%2==0:
    t+=1
  if A[i]>B[i]:
    cnt+=(A[i]-B[i])
  elif A[i]<B[i] and (B[i]-A[i])%2==0:
    cnt+=(B[i]-A[i])/2
  elif A[i]<B[i] and (B[i]-A[i])%2==1:
    cnt+=(B[i]-A[i]+3)/2

if res<0:
  print("No")
elif res*2<cnt:
  print("No")
elif abs(s-t)>res:
  print("No")
elif (res-abs(s-t))%2==1:
  print("No")
else:
  print("Yes")

Submission status: Accepted

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

import sys


def solve(N, A, B):
    max_try = sum(B) - sum(A)

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

    rest_a_try = max_try - a_try
    rest_b_try = max_try - b_try

    if rest_a_try >= 0 and rest_a_try * 2 == rest_b_try:
        print('Yes')
    else:
        print('No')



def main():
    inputs = sys.stdin.readlines()
    inputs = [s.rstrip('\n').lstrip(' ') for s in inputs]

    N = int(inputs[0])
    a = list(map(int, inputs[1].split()))
    b = list(map(int, inputs[2].split()))

    solve(N, a, b)


if __name__ == '__main__':
    main()

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)
if sa > sb:
    print('No')
    exit()
z = sb - sa

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

if c > z or d > z:
    print('No')
else:
    print('Yes' if (z-c)*2 == z-d else 'No')

Submission status: Accepted

Solution code:
import sys

nN = int(input())

A = [0 for i in range(nN)]
B = [0 for i in range(nN)]

nData = []
nData  = input().rstrip().split(' ')
aT = 0
bT = 0


for i in range(nN):
    A[i] = int(nData[i])
    aT += A[i]

nData  = input().rstrip().split(' ')

for i in range(nN):
    B[i] = int(nData[i])
    bT += B[i]

N = bT - aT

nFlag = 0

if N < 0:
    print('No')
    sys.exit()

elif N == 0:
    for i in range(nN):
        if A[i] != B[i]:
            print('No')
            nFlag = 1
            break

    if nFlag == 0:
        print('Yes')

    sys.exit()

else:
    nCnt = 0
    nCntA = 0
    nCntB = 0
    nDiff = 0
    
    for i in range(nN):
        if A[i] > B[i]:
            nDiff = A[i] - B[i]
            nCntB += nDiff
            
        elif B[i] > A[i]:
            nDiff = B[i] - A[i]
            nTmp = nDiff % 2
            if nTmp == 0:
                nCntA += nDiff/2
            else:
                nCntA += nDiff//2 +1
                nCntB += 1
    
    if (N < nCntA) or (N < nCntB):
        print('No')
    
    elif nCntA == nCntB:
        print('Yes')
    
    else :
        nA = (N - nCntA) * 2
        nB = N - nCntB
        if nA == nB:
            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()))
plus=0;minus=0;co=0
for i in range(N):
    c=a[i]-b[i]
    if c < 0:
        minus-=c
        if c%2==1:
            co+=1
    elif c > 0:
        plus+=c

print("Yes" if minus >= plus*2+co else "No")

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
a = np.array([list(map(int, input().split()))])
b = np.array([list(map(int, input().split()))])

diff = b - a
limit = np.sum(diff)

minus = -sum(diff[diff < 0])
diffp = diff[0 < diff]
result = minus
for d in diffp:
    div = min(int(d / 2), minus)
    minus -= div
    result = d - div * 2
    if limit < result:
        break

if 0 < minus or limit < result:
    print("No")
else:
    print("Yes")

Submission status: Accepted

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

    d = sum(B) - sum(A)

    if d < 0:
        print('No')
        return

    C = [a - b for a, b in zip(A, B)]
    m = sum(((abs(x) + 1) // 2 for x in C if x < 0))

    # print(d, m)

    if abs(m) > d:
        print('No')
        return

    # assert d * 2 + sum((x for x in C if x > 0)) + m == d
    print('Yes')


main()

Submission status: Accepted

Solution code:
import math
n = int(input())
lis1 = list(map(int,input().split()))
lis2 = list(map(int,input().split()))
k = 0
c = 0
s = 0
cou = sum(lis2)-sum(lis1)
if cou < 0:
    print("No")
else:
    for i in range(n):
        if lis1[i] < lis2[i]:
            c += math.ceil((lis2[i] - lis1[i]) / 2)
            if (lis2[i] - lis1[i])%2 == 0:
                k += 1
            else:
                s += 1
    if c > cou:
        print("No")
    elif c == cou:
        print("Yes")
    else:
        if k >= 1:
            print("Yes")
        else:
            print("No")

Submission status: Accepted

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

b=input().split(" ")
b=list(map(int,b))
counta=0
countb=0
for i in range(n):
    if a[i]<b[i]: #a<b
        temp=b[i]-a[i] 
        if temp%2==0:
            counta+=int(temp/2)
            #countb-=int(temp/2)
        else:
            counta+=int((temp+1)/2)
            countb+=1
            
    if a[i]>b[i]:#a>b
        temp=a[i]-b[i]
        countb+=temp
       # counta-=temp
# print(counta)
# print(countb)
if counta>=countb:
    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()))

c = 0
for i in range(N):
   if b[i] - a[i] > 0:
      c += (b[i] - a[i])//2
   elif b[i] - a[i] < 0:
      c += b[i] - a[i]

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

Submission status: Accepted

Solution code:
import numpy as np


def a():
    x, y = map(int, input().split())


def b():
    n = int(input())
    a = np.asarray(list(map(int, input().split())))
    b = np.asarray(list(map(int, input().split())))
    x = b.sum() - a.sum()
    d = b - a
    a_req = 0
    b_req = 0
    for i in d:
        if i <= 0:
            b_req += i // -1
        else:
            a_req += i // 2 + i % 2
            b_req += i % 2
    # total require
    if (a_req >= b_req and (0 < a_req + (a_req - b_req) == x)) or (a_req == 0 and b_req == 0):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    b()

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
a = []
b = []

a = np.array([int(num) for num in input().split(" ")])
b = np.array([int(num) for num in input().split(" ")])

flag = False
M = sum(b) - sum(a)

a_count = 0
b_count = 0
c = b - a
for i in range(N):
    if c[i] < 0:
        b_count -= c[i]
    if c[i] > 0:
        count = c[i] % 2
        a_count += count
        b_count += count
        a_count += c[i] // 2
        
if M - b_count == (M - a_count) * 2:
        flag = True
if a_count > M or b_count > M:
    flag = False
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import math
n = input()
a = map(int, raw_input().split())
b = map(int, raw_input().split())
c = 0
for i, j in zip(a, b):
    if i < j:
        c += math.ceil(1.0*(j-i)/2)
if c > sum(b)-sum(a):
    print "No"
else:
    print "Yes"

Submission status: Accepted

Solution code:
n=int(input())

x=[int(i) for i in input().split()]
y=[int(i) for i in input().split()]
y_plus=0
xy_dif=0

for i in range(n):
    if x[i]<y[i] and (x[i]-y[i])%2==0:
        y_plus=y_plus+int(0.5*(y[i]-x[i]))
        x[i]=y[i]
    elif x[i]<y[i] and (x[i]-y[i])%2==1:
        y_plus=y_plus+int(0.5*(y[i]-x[i]+1))
        x[i]=y[i]+1
        xy_dif=xy_dif+1
    else:
        xy_dif=xy_dif+x[i]-y[i]


#print(x)
#print(y_plus,xy_dif)

if xy_dif<=y_plus:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import math

N = int(input())
a_list = list(map(int, input().split(' ')))
b_list = list(map(int, input().split(' ')))

cnt = sum(b_list) - sum(a_list)

cnt_tmp = 0
for i in range(N):
    if a_list[i] < b_list[i]:
        cnt_tmp += math.ceil((b_list[i] - a_list[i]) / 2)

if cnt_tmp > cnt:
    print('No')
else:
    print('Yes')

Submission status: Accepted

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

N = int(input())
A = inpl()
B = inpl()

C = 0
D = 0

for a, b in zip(A, B):
    if b - a > 1:
        C += (b-a) - ((b-a)%2)
    else:
        D += (a-b)

if C >= 2*D:
    print("Yes")
else:
    print("No")