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**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    A=LI()
    B=LI()
    cnt1=0
    cnt2=0
    cnt3=0
    for a,b in zip(A,B):
        if a>b:
            cnt1 += a-b
        else:
            cnt2 += b-a
            if (b-a)&1:
                cnt3+=1
    # print(cnt1,cnt2,cnt3)
    if cnt1*2+cnt3<=cnt2:
        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()))

ac=0
bc=0
for i in range(N):
  a,b=A[i],B[i]
  if a>b:
    bc+=a-b
  elif a<b:
    if (b-a)%2==0:
      ac+=(b-a)//2
    else:
      ac+=(b-a)//2+1
      bc+=1
      
if ac>=bc:
  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


if sum(a)>sum(b):
    print('No')
    exit()

else:
    for i in range(n):
        if a[i]<b[i]:
            count+=-(-(b[i]-a[i])//2)
    
    v=sum(b)-sum(a)
    if v>=count:
        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()))

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

times_b = 0
for i in range(n):
    if b[i] < a[i]:
        times_b += a[i] - b[i]

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

if times_b + common <= times:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]

def main():
    n=inp()
    a=inpl()
    b=inpl()
    dif = sum(b) - sum(a)
    for i in range(n):
        if a[i]<b[i]:
            dif -= (b[i]-a[i])//2 + (b[i]-a[i])%2
    if dif < 0:
        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()))
ab = list(zip(A, B))
c1, c2 = 0, 0
for a, b in ab:
  if a >= b:
    c1 += a-b
  else:
    c2 += (b-a)//2
if c2 >= c1:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


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

A = np.array(A, dtype=int)
B = np.array(B, dtype=int)

count = B.sum() - A.sum()

ac = 0
bc = 0
for a, b in zip(A, B):
    if b < a:
        bc += a - b
    if a < b:
        if (b - a) % 2 == 0:
            ac += (b - a) // 2
        else:
            ac += (b - a) // 2 + 1
            bc += 1
if ac > bc:
    x = ac - bc
    ac += x
    bc += 2 * x

ok = bc == ac and bc == count
if ok:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import numpy as np

N = int(input())
A = np.array(input().split(), dtype=np.int32)
B = np.array(input().split(), dtype=np.int32)

sum_a = A.sum()
sum_b = B.sum()
time = (B-A).sum()
if time < 0:
    print('No')
    exit()
time2 = (((B-A)[B>A]+1) // 2).sum()
if time < time2:
    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()))
a_b = b_a = 0
for a, b in zip(A, B):
    a_b += max(0, a-b) + max(0, (b-a))%2
    b_a += max(0, (b-a+1)//2)
t = max(a_b, b_a)
#print(t)
if sum(B)-sum(A) >= t:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())
an = [int(i) for i in input().split()]
bn = [int(i) for i in input().split()]
x,y = 0,0
for a,b in zip(an,bn):
  if a >= b:
    x += a-b
  else:
    y += (b-a)//2
print('Yes' if y >= x else 'No')

Submission status: Accepted

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

x,y=0,0
for i,j in zip(a,b):
  if i>j:x+=i-j
  else:y+=(j-i)//2
print('Yes' if y >= x else '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
    else:
        count+=(B[i]-A[i])
    
if count<0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
n,*L=map(int,open(0).read().split());s=sum(j-i-max(0,i-j)-max(0,j-i)%2for i,j in zip(L,L[n:]));print("NYoe s"[s>=0==s%2::2])

Submission status: Accepted

Solution code:
n = int(input())
*a, = map(int, input().split())
*b, = map(int, input().split())
k = l = 0
for i, j in zip(a, b):
	k += j - i
	l += max(0, i - j) + max(0, j - i) % 2
if k >= l and (k - l) % 2 == 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()))
c = []

for i in range(N):
    c.append(a[i]-b[i])

#print (c)

mi = 0
pl = 0

for i in c:
    if i < 0:
        mi += abs(i) // 2
    else:
        pl += i

if mi < pl:
    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):
    if a[i]<b[i]:
        cnt+=(b[i]-a[i])//2
    else:
        cnt-=a[i]-b[i]

if cnt<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()))

cnt1=0
cnt2=0
ma=sum(b)-sum(a)
if ma<0:
    print("No")
    exit()

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)

def main():
    n = int(input().strip())
    a = list(map(int, input().strip().split()))
    b = list(map(int, input().strip().split()))
    cnt = 0

    k = sum(max(0, a[i]-b[i]) for i in range(n))
    l = sum(max(0, (b[i] - a[i])//2) for i in range(n))
    if k <= l:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
la=list(map(int,input().split()))
lb=list(map(int,input().split()))
limit=0
must=0
for i in range(n):
  if la[i]>lb[i]:
    must+=la[i]-lb[i]
  elif la[i]==lb[i]:
    pass
  else:
    limit+=(lb[i]-la[i])//2
if limit<must:
  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 = sum(B) - sum(A)
each = 0
for i in range(N):
    if B[i] == A[i]:
        continue
    elif B[i] - A[i] > 0:
        each += math.ceil((B[i] - A[i]) / 2)
if each <= total:
    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]:
        s=(b[i]-a[i])//2
        count+=s
    else:
        s=a[i]-b[i]
        count-=s
if count>=0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
def main():
    n=int(input())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    counta = 0
    countb = 0
    for i in range(n):
        if a[i] > b[i]:
            countb += a[i] - b[i]
        elif a[i] < b[i]:
            counta += (b[i] - a[i] + 1) // 2
            if (b[i]-a[i]) % 2 == 1:
                countb += 1

    if countb > counta:
        return "No"
    else:
        return "Yes"

print(main())

Submission status: Accepted

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

diff = sum(b) - sum(a)
if diff < 0:
    print("No")
else:
    count = 0
    count2 = 0
    for i in range(N):
        if a[i] > b[i]:
            count += a[i] - b[i]
        elif a[i] < b[i]:
            count2 += math.ceil((b[i] - a[i])/2)
    if max(count, count2) > diff:
        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()))
s = sum(b) - sum(a)
s, t = 0, 0
for i in range(n):
    if a[i] < b[i]:
        if (b[i] - a[i]) % 2:
            s += 1
            t += 1
        s += (b[i] - a[i]) // 2
    else:
        t += (a[i] - b[i])
if s < max(s, t):
    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 a,b in zip(A,B):
  if a>b:
    cnt+=a-b
  else:
    cnt-=(b-a)//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()))
c = [0] * n
f = 0
for i in range(n):
    c[i] = b[i] - a[i]
    if c[i] >= 0:
        f += c[i] //2
    else:
        f += c[i]

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

Submission status: Accepted

Solution code:
# APC001B - Two Arrays
def main():
    N, *AB = map(int, open(0).read().split())
    A, B = AB[:N], AB[N:]
    cnt = 0
    for a, b in zip(A, B):
        if a > b:
            cnt += a - b
        else:
            cnt -= (b - a) // 2
    print("Yes" if cnt <= 0 else "No")


if __name__ == "__main__":
    main()

Submission status: Accepted

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

a_cnt = 0
b_cnt = 0
for i in range(N):
    if a[i] >= b[i]:
        b_cnt += a[i] - b[i]
    else:
        if (b[i] - a[i]) % 2 == 0:
            a_cnt += b[i] - a[i]
        else:
            a_cnt += b[i] - a[i] - 1
if b_cnt * 2 <= a_cnt:
    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()))

#(方針)和の差分の回数(n回)で合わせられるか(1回の操作で和の差が1ずつ小さくなる)　
#ex 1 2 3 / 5 2 2 -> (和)6 9 -> 3回の操作
#・aにする操作 n回 / ・bにする操作 n回　ばらばらに考える
#・とりあえず対応要素の差が0になるように操作

num = sum(B) - sum(A) #操作回数
judge = 1 

if(num < 0): judge = 0
elif(num == 0): 
  if(A==B): judge = 1
  else: judge = 0
else:
  count_a,count_b = 0,0 #現在のaの操作回数 ,bの操作回数
  for i in range(N):
    if(A[i] < B[i]): #bが大きい
      dif = B[i]-A[i]
      if(dif%2 == 0): 
        count_a += dif//2
      else: 
        count_a += (dif//2)+1
        count_b += 1
        
    elif(A[i] > B[i]): #aが大きい
      dif = A[i] - B[i]
      count_b += dif
    
    if((count_a > num)or(count_b > num)) : #不可
      judge = 0
      break
      
  if(judge == 1): #全ての操作後,余りで合わせられるか
    if((num-count_a)*2 != (num-count_b)):
      judge = 0

if(judge == 0): print('No')
else: print('Yes')

Submission status: Accepted

Solution code:
N,*A=map(int,open(0).read().split());print("YNeos"[sum((b-a+1)//2for a,b in zip(A[:N],A[N:])if b>a)>sum(A[N:])-sum(A[:N])::2])

Submission status: Accepted

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

if sum(A)>sum(B):
  print("No")
else:
  cnt=sum(B)-sum(A)
  for i in range(N):
    if A[i]<B[i]:
      cnt-=(B[i]-A[i])//2+(B[i]-A[i])%2
  print("Yes" if cnt>=0 else "No")

Submission status: Accepted

Solution code:
import math


def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    operations = sum(b) - sum(a)
    o1, o2 = 0, 0
    for ai, bi in zip(a, b):
        if ai >= bi:
            o1 += ai - bi
        else:
            if (bi - ai) / 2 % 1 == 0:
                o2 += (bi - ai) // 2
            else:
                o2 += (bi - ai) // 2 + 1

    print("Yes" if o1 <= operations and o2 <= operations else "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()))
count=0
for a,b in zip(A,B):
   if a>b:count -=a-b
   else:count +=(b-a)//2

print("Yes" if count>=0 else "No")

Submission status: Accepted

Solution code:
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
count=0
all=sum(B)-sum(A)
for a,b in zip(A,B):
   if a>b:count -=a-b
   elif b>a:count +=(b-a)//2

print("Yes" if count>=0 else "No")

Submission status: Accepted

Solution code:
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
count=0
for a,b in zip(A,B):
   if a>b:count -=a-b
   elif b>a:count +=(b-a)//2

print("Yes" if count>=0 else "No")

Submission status: Accepted

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


def main():
    from math import ceil

    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    sum_a = sum(a)
    sum_b = sum(b)
    operation_count = sum_b - sum_a

    # 数列bの合計は数列aの合計よりも大きい必要がある
    if operation_count >= 0:
        # KeyInsight
        # https://img.atcoder.jp/apc001/editorial.pdf
        # 条件を満たすために，少なくとも何回操作が必要か?
        # ai < biのとき少なくとも[(bi - ai) / 2]回，+2する必要がある
        # ai > biのとき少なくともai - bi回，+1する必要がある
        # 操作回数より大きくなければYes
        two_count = 0
        one_count = 0

        for ai, bi in zip(a, b):
            if ai > bi:
                one_count += ai - bi
            elif ai < bi:
                two_count += ceil((bi - ai) / 2)

        if one_count <= operation_count and two_count <= operation_count:
            print('Yes')
        else:
            print('No')
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Accepted

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

def ceil(a, b):
    if a%b == 0:
        return a//b
    else:
        return a//b + 1

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

    count = sum(b) - sum(a)

    one = 0
    two = 0
    for i in range(N):
        if a[i] >= b[i]:
            one += a[i] - b[i]
        else:
            two += ceil(b[i]-a[i], 2)
    
    if one <= count and two <= count:
        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 a, b in zip(A, B):
    if a > b:  # 特殊操作（他のaの力が）が必要な場合
        cnt -= a-b
    if a < b:  # 他のbに力を貸せる場合
        cnt += int((b-a)/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()))

cnt = 0
for a, b in zip(A, B):
    if a > b:  # 特殊操作（他のaの力が）が必要な場合
        cnt -= a-b
    if a < b:  # 他のaに力を貸せる場合
        cnt += int((b-a)/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()))

sa = 0
sb = 0
for i in range(N):
  if A[i] < B [i]:
    sa += (B[i] - A[i] + 1) // 2
  else:
    sb += A[i] - B[i]
s = sum(B) - sum(A)
if s < 0 or sa > s or sb > s:
  print('No')
  exit()
print('Yes')

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

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

Submission status: Accepted

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

total = sum(b) - sum(a)

one = 0
two = 0
for i, j in zip(a, b):
  if i > j:
    one += i - j
  elif i < j:
    two += ceil((j - i) / 2)
    
if total >= one and total >= two:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
from collections import defaultdict

def getlist():
	return list(map(int, input().split()))

N = int(input())
a = getlist()
b = getlist()
c = [b[i] - a[i] for i in range(N)]

n = sum(c)
if n < 0:
	print("No")
else:
	m = 0
	for i in range(N):
		x = c[i]
		if x >= 1:
			if x % 2 == 0:
				m += x // 2
				c[i] = 0
			else:
				m += x // 2 + 1
				c[i] = -1
	if n >= m:
		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()))

# 任意のiに対して ai <= bi にできればよい

lessA = 0
lessB = 0

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

if lessB <= lessA:
    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()))

if sum(A) > sum(B):
    print('No')
    exit()

d = 0
for i in range(N):
    if B[i] > A[i]:  # B[i]の方が大きい時
        d += (B[i]-A[i])//2
    else:  # A[i]がB[i]以上の時
        d -= A[i]-B[i]

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

Submission status: Accepted

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

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

    if add1 <= ans and add2 <= ans:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def conb(n,r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
#https://atcoder.jp/contests/apc001/tasks/apc001_b
import sys
#import collections

n= int(input())
#s= input()
tmp = input().split()
a = list(map(lambda a: int(a), tmp))
tmp = input().split()
b = list(map(lambda a: int(a), tmp))

totala=0
totalb=0
odd=0
num=0
for i in range(n):
	totala+=a[i]
	totalb+=b[i]
	if(b[i]>a[i]):
		num+=(b[i]-a[i]+1)//2
#	elif(

#print(num)
#print(totalb-totala)
if(num<=totalb-totala):
	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()))


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

if bsup >= asup:
    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()]

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

if cb >= ca:
    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):
  cnt+=max(0, (b[i]-a[i])//2+(b[i]-a[i])%2)
if sum(b)-sum(a)<cnt:
  print('No')
  exit()

print('Yes')

Submission status: Accepted

Solution code:
import math
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
opr = sum(B)-sum(A)
cnt = 0
for i in range(N):
    if(B[i]>A[i]):
        cnt += math.ceil((B[i]-A[i])/2)
if(cnt>opr):
    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()))

tA = 0
tB = 0
for i in range(N-1):

    if A[i] < B[i]:
        M = B[i] - A[i]
        C = M//2
        if tA >= C:
            tA -= C
        else:
            D = C - tA
            tA = 0
            tB += D

    elif A[i] > B[i]:
        M = A[i] - B[i]
        C = M
        if tB >= C:
            tB -= C
        else:
            D = C - tB
            tB = 0
            tA += D

a = A[-1]
b = B[-1]
a += 2*tA
b += tB
if a <= b:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

n = I()
a = LI()
b = LI()
one,two = 0,0
for i in range(n):
    x = a[i] - b[i]
    if x == 0:
        continue
    if x > 0:
        one += x
        continue
    if x < 0:
        if x % 2:
            x -= 1
            one += 1
        two += (-x)//2
if one <= two:
    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()))

act=sum(B)-sum(A)
if act<0:
    print("No")
else:

    cnt=0
    for a,b in zip(A, B):
        if a<=b:
            cnt+=int((b-a+1)/2)
    if cnt<=act:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
import math

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

count_a = 0
count_b = 0

#必要最低限の操作数を調べる
for i in range(n):
  if a[i]<b[i]:
    count_a += math.ceil((b[i]-a[i])/2)
    if (b[i]-a[i])%2 == 1:
      count_b += 1
  elif a[i] > b[i]:
    count_b += a[i]-b[i]
    
if count_b <= count_a:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res

def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

n = I()
a = LI()
b = LI()
s = 0
for i in range(n):
    if a[i] < b[i]:
        k = b[i]-a[i]
        k += k&1
        s += (k>>1)
        a[i] += k
for i in range(n):
    if b[i] < a[i]:
        k = a[i]-b[i]
        if s < k:
            print("No")
            quit()
        b[i] += k
        s -= k
print("Yes")

Submission status: Accepted

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

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

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

# +2 or -1

two = 0
one = 0
for x in A:
    if x == 0:
        continue
    if x > 0:
        one += x
        continue
    if x < 0:
        if x&1:
            x -= 1
            one += 1
        two += (-x)//2

answer = 'Yes' if one <= two else 'No'
print(answer)

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
if sum(A)>sum(B):print("No")
else:
    c,d=0,0
    for i in range(N):
        if A[i]>=B[i]:c+=A[i]-B[i]
        else:d+=(B[i]-A[i])//2
    if c>d: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()))

ab=0
ba=0
if sum(a)>sum(b):
    ans="No"
else:
    for i in range(N):
        abtmp=max(a[i]-b[i],0)
        ab+=abtmp
        batmp=max(b[i]-a[i],0)
        ba+=batmp//2
    if ab>ba:
        ans="No"
    else:
        ans="Yes"

print(ans)

Submission status: Accepted

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

def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    B = [int(b) for b in input().split()]
    
    A_put = 0
    B_put = 0
    
    for i in range(N):
        if A[i]<B[i]:
            A_put += (B[i]-A[i])//2
        else:
            B_put += A[i]-B[i]
            
    if A_put>=B_put:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())
A,B=[map(int,input().split()) for _ in range(2)]
cnt1,cnt2=0,0
for a, b in zip(A,B):
    if b-a >= 2:
        cnt2 += (b-a)//2
    elif b-a < 0:
        cnt1 += (a-b)
print("Yes" if cnt1<=cnt2 else "No")

Submission status: Accepted

Solution code:
import math

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

c = 0
d = 0
if sum(a) > sum(b):
    print('No')
else:
    for i in range(N):
        c += max(0, a[i]-b[i])
        d += max(0, (b[i]-a[i])//2)
    if c > d:
        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()))
    cnt = sum(B) - sum(A)
    acnt = 0
    bcnt = 0
    for i in range(N):
        x = B[i] - A[i]
        if x > 0:
            acnt += x//2
            if x % 2 == 1:
                acnt += 1
                bcnt += 1
        elif x < 0:
            bcnt += 1
    if acnt <= cnt and bcnt <= cnt:
        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()))
p,q=0,0
for i in range(n):
    a=A[i]
    b=B[i]
    if a>b:
        q+=a-b
    else:
        if (b-a)%2==0:
            p+=(b-a)//2
        else:
            p+=(b-a)//2+1
            q+=1
if q<=p:
    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()))
cnt1 = cnt2 = 0
for i in range(n):
    if a[i] <= b[i]:
        cnt1 += (b[i] - a[i]) // 2
    else:
        cnt2 += a[i] - b[i]
print("Yes" if cnt1 >= cnt2 else "No")