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

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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

    acnt = 0
    bcnt = 0

    for i in range(N):
        if A[i] == B[i]:
            continue
        elif A[i] > B[i]:
            bcnt += A[i] - B[i]
        else:
            acnt += -(-(B[i] - A[i]) // 2)
            bcnt += (B[i] - A[i]) % 2

    if acnt < bcnt:
        print("No")
    else:
        print("Yes")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())

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

#a.sort()
#b.sort()

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

suma=sum(a)
sumb=sum(b)


#sum(a)+2*k=sum(b)+k
#k=(sum(a)-sum(b))

k=sumb-suma
#
#1 1 1 6
#2 2 2 3

cnta=0
cntb=0
for i in range(n):
    if a[i]>b[i]:
        cntb+=a[i]-b[i]
    elif a[i]<b[i]:
        cnta+=(-1)*((a[i]-b[i])//2)
#print(k,cntb,cnta)
if cntb<=k and cnta<=k:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# a_i <= b_iなら同じidxを選ぶことで揃えられる

# 操作A : a_i > b_i で b_i +=1
# sum(a-b)回「行う必要がある」

# 操作B : a_j < b_j で (この条件を外れない範囲まで)a_j +=2
# sum((b-a)//2) 回「まで行える」
# ex. b-a==1 なら操作Bは行えない

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

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

if lb >= la:
    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()))

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

if lb >= la:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def ceil(x, y):
    return -(-x // y)


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

    sa = sum(B) - sum(A)

    x = 0
    y = 0
    for i in range(N):
        if A[i] == B[i]:
            continue
        elif A[i] > B[i]:
            x += A[i] - B[i]
        else:
            y += ceil(B[i] - A[i], 2)

    if x <= sa and y <= sa:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def ceil(x, y):
    return -(-x // y)


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

    bamari = 0
    for i in range(N):
        if A[i] == B[i]:
            continue
        elif A[i] > B[i]:
            bamari -= A[i] - B[i]
        else:
            bamari += ceil(B[i] - A[i], 2)
            bamari -= (B[i] - A[i]) % 2

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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


    bamari = 0
    for i in range(N):
        if A[i] == B[i]:
            continue
        elif A[i] > B[i]:
            bamari -= A[i] - B[i]
        else:
            bamari += -(-(B[i] - A[i]) // 2)
            bamari -= (B[i] - A[i]) % 2

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
(n,),aa,bb = [list(map(int, s.split())) for s in open(0)]

up = down = 0

for i in range(n):
    a = aa[i]
    b = bb[i]
    if a > b:
        down += a-b
    if b > a:
        d,m = divmod(b-a,2)
        up += d+m
        down += m

diff = sum(bb) - sum(aa)

if up <= diff and down <= diff:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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

    n = sum(B) - sum(A)
    if n < 0:
        print("No")
        exit()

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

    ans = "Yes" if n_need <= n else "No"
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

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

    if bb >= ba:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N,*f = map(int, open(0).read().split())
ab = [f[i] - f[i+N] for i in range(N)]
c = 0
d = 0
for x in ab:
    if x < 0:
        c += abs(x) // 2
    elif x > 0:
        d += x
if c >= d:
    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()))

result = False

big_a = sum([ai - bi for ai, bi in zip(a,b) if ai > bi])
big_b = sum([(bi - ai) // 2 for ai, bi in zip(a,b) if bi > ai])
sum_diff = sum(b) - sum(a)

if big_a <= big_b:
  result = True

ans = "Yes" if result else "No"
print(ans)

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)
cb = sum([a-b for b,a in zip(B,A) if b<a])
ca = sum([(b-a+1)//2 for b,a in zip(B,A) if b>a])
if ca<=k and cb<= k:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
import math

N = int(input())

As = list(map(int, input().split()))
Bs = list(map(int, input().split()))

if sum(As) > sum(Bs):
  print('No')
  exit()
  
dif = sum(Bs) - sum(As)
A = 0
for i in range(N):
  if Bs[i] > As[i]:
    A += math.ceil((Bs[i]-As[i])/2)
    
if A > dif:
  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()))

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

if bb >= ba:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

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

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

Submission status: Accepted

Solution code:
import sys

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
B = list(map(int, sys.stdin.readline().split()))
# print(A)
# print(B)

# a <= b のところは一致させることができる
# a > b となっているところを a = b にするのに必要な+1の操作数を、
# a <= b となっているところが a <= b のままである「余裕な走査数」が上回っていれば良い
need_an = 0
need_bn = 0
for i in range(N):
    if A[i] > B[i]:
        need_bn += A[i] - B[i]
    elif A[i] < B[i]:
        need_an += (B[i] - A[i]) // 2

# print(need_an, need_bn)
if need_an >= need_bn:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
def main():
    import sys

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

    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    s = 0
    sm = 0
    for x, y in zip(a,b):
        tmp = y-x
        sm += tmp
        if tmp > 0:
            tmp //= 2
        s += tmp
    if s >= 0 and sm >= 0:
        print('Yes')
    else:
        print('No')

    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
B = list(map(int, sys.stdin.readline().split()))
# print(A)
# print(B)

sum_a = sum(A)
sum_b = sum(B)
need_n = sum_b - sum_a

need_an = 0
need_bn = 0
for i in range(N):
    if A[i] > B[i]:
        need_bn += A[i] - B[i]
    elif A[i] < B[i]:
        tmp = B[i] - A[i]
        need_an += tmp // 2

# print(need_n, need_an, need_bn)
if sum_a <= sum_b and need_an >= need_bn:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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


def main():
    n = int(input())
    A = [int(i) for i in input().strip().split()]
    B = [int(i) for i in input().strip().split()]

    _diff_A, _diff_B = 0, 0
    m = sum(B) - sum(A)  # 操作回数の上限
    for i in range(n):
        if A[i] > B[i]:
            _diff_A += A[i] - B[i]
        elif B[i] > A[i]:
            _diff_B += (B[i] - A[i] + 1) // 2

    if _diff_B <= m and _diff_A <= m:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Submission status: Accepted

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


def main():
    n = int(input())
    A = [int(i) for i in input().strip().split()]
    B = [int(i) for i in input().strip().split()]

    _diff_A, _diff_B = 0, 0
    m = sum(B) - sum(A)
    for i in range(n):
        if A[i] > B[i]:
            _diff_A += A[i] - B[i]
        elif B[i] > A[i]:
            _diff_B += (B[i] - A[i] + 1) // 2

    if _diff_B <= m and _diff_A <= m:
        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()))

cnt = 0

for i in range(n):
    if a[i] > b[i]:
        k = a[i] - b[i]
        b[i] += k
        cnt += k

for i in range(n):
    if a[i] < b[i]:
        k = (b[i] - a[i]) // 2
        a[i] += 2 * k
        cnt -= k
        if a[i] < b[i]:
            a[i] += 2
            b[i] += 1

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

Submission status: Accepted

Solution code:
n = int(input())
a_ls = list(map(int, input().split()))
b_ls = list(map(int, input().split()))
times_add = 0
diff_to_pad = 0
for i in range(n):
    diff = b_ls[i] - a_ls[i]
    if diff > 0:
        times_add += -(-diff//2) 
        if diff % 2 == 1:
            diff_to_pad += 1
    elif diff < 0:
        diff_to_pad += -diff
if diff_to_pad > times_add:
    res = 'No'
else:
    res = 'Yes'
print(res)

Submission status: Accepted

Solution code:
n,*a=map(int,open(0).read().split())
print("Yes" if sum((j-i)//2*2 if j-i>0 else 2*(j-i)for i,j in zip(a[:n],a[n:]))>=0 else "No")

Submission status: Accepted

Solution code:
n,*a=map(int,open(0).read().split());print("Yes" if sum((j-i)//2*2 if j-i>0 else 2*(j-i)for i,j in zip(a[:n],a[n:]))>=0 else "No")

Submission status: Accepted

Solution code:
n,*a=map(int,open(0).read().split())
u=d=z=r=0
for i,j in zip(a[:n],a[n:]):
    if j-i>0:u+=(j-i)//2*2;r+=(j-i)%2
    elif j-i==0:z+=1
    else:d+=j-i
print("Yes" if u+2*d>=0 else "No")

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
cou = 0
for j,k in zip(a,b):
  if j<k:
    cou += (k-j)//2
  elif j>k:
    cou -= (j-k)
if cou>=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()))
out = "No"
SBA = sum(B)-sum(A)
if SBA>=0:
    cnt = 0
    for i in range(N):
        if A[i]<B[i]:
            cnt += (B[i]-A[i]+1)//2
    if cnt<=SBA:
        out = "Yes"
print(out)

Submission status: Accepted

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


c1=0
c2=0

from math import floor
for i in range(n):
    if a[i]>b[i]:
        c1+=a[i]-b[i]
    elif a[i]<b[i]:
        c2+=floor((b[i]-a[i])/2)

if c2>=c1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())
alst = list(map(int, input().split()))
blst = list(map(int, input().split()))
k = sum(blst) - sum(alst)
cnt = 0
for a, b in zip(alst, blst):
    cnt += max(0, (b - a + 1) // 2)
if cnt <= k:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

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

    # 全てのiに対してa[i]<=b[i]にしていく
    tmp = 0
    for i in range(N):
        if a[i] > b[i]:
            tmp += a[i] - b[i]
        else:
            tmp -= (b[i] - a[i]) // 2

    if tmp <= 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()))

m = sum(B)-sum(A)
cnt1 = 0
cnt2 = 0
for a, b in zip(A, B):
    if a > b:
        cnt1 += (a-b)
    elif a < b:
        cnt2 += (b-a+1)//2
    else:
        pass

if cnt1 <= m and cnt2 <= m:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = readInts()
B = readInts()
biga = 0
bigb = 0
for i in range(n):
    if A[i] > B[i]:
        biga += A[i]-B[i]
    elif A[i] < B[i]:
        bigb += (B[i]-A[i])//2
print('Yes' if bigb >= biga else 'No')

Submission status: Accepted

Solution code:
def check():
  N = int(input())
  A = list(map(int, input().split()))
  B = list(map(int, input().split()))
  diff = sum(B)-sum(A)
  if diff < 0:
    return 'No'
  cnt = 0
  for i in range(N):
    cnt += max((B[i]-A[i]+1)//2,0)
  if diff < cnt:
    return 'No'
  return 'Yes'
print(check())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import sys


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


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


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

    op = sum(B) - sum(A)
    p = 0
    for i in range(N):
        if B[i] > A[i]:
            p += math.ceil((B[i] - A[i]) / 2)

    if p > op:
        print("No")
    else:

        print("Yes")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = LIST()
b = LIST()

ma = mb = 0
for i in range(n):
    if a[i] < b[i]:
        if ( b[i] - a[i] ) % 2 == 0:
            ma += ( b[i] - a[i] ) // 2
        else:
            ma += ( b[i] - a[i] ) // 2 + 1
            mb += 1
    else:
        mb += a[i] - b[i]

if ma >= mb:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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

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

    diff = sum(B) - sum(A)
    if n_1 <= diff and n_2 <= diff:
        ans = "Yes"
    else:
        ans = "No"
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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

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

    diff = sum(B) - sum(A)
    if diff < 0:
        ans = "No"
    elif n_1 <= diff and n_2 <= diff:
        ans = "Yes"
    else:
        ans = "No"
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))

margin = 0 # b側で加算可能な回数
for a,b in zip(a_list, b_list):
    if a == b:
        continue
    elif a < b:
        margin -= (b-a)//2
    else:
        margin += a-b

if margin <= 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()))

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

Submission status: Accepted

Solution code:
n = int(input())
c = 0
for i,j in zip(map(int,input().split()),map(int,input().split())):
  if i > j:
    c -= i-j
  else:
    c += (j-i)//2
print('YNeos'[c<0::2])

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
score = 0
for a, b in zip(A, B):
    diff = b - a
    if diff > 0:
        score += diff // 2
    else:
        score += diff
print("Yes") if score >= 0 else print("No")

Submission status: Accepted

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

difflist=[]
for i in range(n):
	difflist.append(blist[i]-alist[i])

needcount=sum(difflist)
if needcount < 0:
	print("No")
	sys.exit()
elif needcount == 0:
	for diff in difflist:
		if diff != 0:
			print("No")
			sys.exit()
	print("Yes")
	sys.exit()

posineed=0
neganeed=0

for diff in difflist:
	if diff < 0:
		neganeed += -diff
	elif diff > 0:
		posineed += diff // 2
	if diff % 2 == 1:
		posineed += 1
		neganeed += 1

if posineed >= neganeed:
	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 a,b in zip(A,B):
    c += min((b-a)//2, b-a)
print('Yes' if c>=0 else 'No')

Submission status: Accepted

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

cnt = sum(b) - sum(a)
ans1, ans2 = 0, 0
for ai, bi in zip(a, b):
    ans1 += max(0, ai - bi)
    ans2 += max(0, (bi - ai + 1) // 2)
print('Yes' if max(ans1, ans2) <= cnt else 'No')

Submission status: Accepted

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

cnt = sum(b) - sum(a)
ans = 0
for ai, bi in zip(a, b):
    ans += max(0, (bi - ai + 1) // 2)
print('Yes' if ans <= cnt else 'No')

Submission status: Accepted

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

N = INT()
a = LIST()
b = LIST()

a_cnt = 0
b_cnt = 0

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


if b_cnt <= a_cnt:
	print("Yes")
else:
	print("No")

Submission status: Accepted

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

N = INT()
a = LIST()
b = LIST()

a_cnt = 0
b_cnt = 0

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


if b_cnt <= a_cnt:
	print("Yes")
else:
	print("No")

Submission status: Accepted

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

N = INT()
a = LIST()
b = LIST()

a_cnt = 0
b_cnt = 0

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


if b_cnt <= a_cnt:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N = in_n()
    a = in_nl()
    b = in_nl()

    count = sum(b) - sum(a)

    x, y = 0, 0
    for i in range(N):
        if a[i] == b[i]:
            continue
        elif a[i] > b[i]:
            y += a[i] - b[i]
        else:
            t = b[i] - a[i]
            if t % 2 == 0:
                x += t // 2
            else:
                x += t // 2 + 1
                y += 1

    if count < 0:
        ans = 'No'
    else:
        if count < x or count < y:
            ans = 'No'
        else:
            if y + 2 * (count - x) == count:
                ans = 'Yes'
            else:
                ans = 'No'

    # print(count)
    #print(x, y)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	n=II()
	A=LI()
	B=LI()
	pos=0
	neg=0

	for i,j in zip(A,B):
		if j-i>=0:
			pos+=(j-i)//2
		else:
			neg+=-j+i
	if pos>=neg:
		ans="Yes"
	else:
		ans="No"

	print(ans)






if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
n = int(input())
li_a = list(map(int, input().split()))
li_b = list(map(int, input().split()))
delta = sum(li_b) - sum(li_a)
if delta < 0:
    print('No')
    exit()
elif delta == 0:
    if li_a == li_b:
        print('Yes')
        exit()
    else:
        print('No')
        exit()
else:
    li_d = []
    for i in range(n):
        li_d.append(li_b[i]-li_a[i])
    pa = 0
    pb = 0
    for i in li_d:
        if i >=0:
            pa += (i+1)//2
        else:
            pb += i
    if delta < max(pa, pb):
        print('No')
    else:
        print('Yes')

Submission status: Accepted

Solution code:
# coding: utf-8
# hello worldと表示する
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis1=LI()
lis2=LI()
u=sum(lis2)-sum(lis1)
count=0
if u<0:
    print("No")
    exit()
for i in range(n):
    count+=-(-max(0,lis2[i]-lis1[i])//2)
#print(count)
if count<=u:
    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()))

operation_num = sum(b) - sum(a)
x = 0 # 操作回数
y = 0
z = 0
for i in range(n):
    x += b[i]-a[i]
    y += max(a[i]-b[i], 0)
    z += max(math.ceil((b[i]-a[i])/2), 0)
# print(x, y)
if x - y < 0 or x - z < 0:
    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()))
cp = 0
cm = 0
for i in range(N):
    if A[i]>B[i]:
        cm += A[i]-B[i]
    elif B[i]>A[i]:
        cp += (B[i]-A[i])//2
if cp>=cm:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

def main():
    mod=10**9+7
    N=I()
    A=LI()
    B=LI()
    a=0
    b=0
    for i in range(N):
        if A[i]>B[i]:
            b+=A[i]-B[i]
        elif (B[i]-A[i])%2==0:
            a+=(B[i]-A[i])//2
        else:
            a+=(B[i]+1-A[i])//2
            b+=1
            
    if a>=b:
        print("Yes")
    else:
        print("No")
    

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)
counta = 0
countb = 0
for i,j in zip(a,b):
    if j > i:
        if (j-i)%2:
            countb += 1
        counta += (j-i+1)//2
    elif i > j:
        countb += i-j
if counta <= sb-sa and countb <= sb-sa:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

k = sum(b) - sum(a)
m = [(max(a[i], b[i])+(a[i]<b[i] and (b[i]-a[i])%2==1)) for i in range(n)]
if k>=0 and sum(a)+2*k>=sum(m) and sum(b)+k>=sum(m):
    ans = "Yes"
else:
    ans = "No"
print(ans)