Problem:


Score : 300 points

Problem Statement

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

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

Add 2 to a_i.

Add 1 to b_j.

Constraints

1 ≤ N ≤ 10 000

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

All input values are integers.

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 .. a_N
b_1 b_2 .. b_N

Output

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

Sample Input 1

3
1 2 3
5 2 2

Sample Output 1

Yes

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

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

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

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

Sample Input 2

5
3 1 4 1 5
2 7 1 8 2

Sample Output 2

No

Sample Input 3

5
2 7 1 8 2
3 1 4 1 5

Sample Output 3

No



Sample input:
3
1 2 3
5 2 2


Sample output:
Yes

Submission status: Accepted

Solution code:
import sys
import numpy as np


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


def main():
    n = int(input())
    al = [int(e) for e in input().split()]
    bl = [int(e) for e in input().split()]

    poscnt = 0
    negcnt = 0
    for i in range(n):
        if al[i] > bl[i]:
            poscnt += al[i] - bl[i]
        elif al[i] < bl[i]:
            negcnt += (bl[i] - al[i]) // 2
    if poscnt <= negcnt:
        print("Yes")
    else:
        print("No")


main()

Submission status: Accepted

Solution code:
n,a,b=int(input()),list(map(int,input().split())),list(map(int,input().split()))
sa=sb=p1=p2=0
for i in range(n):
  sa+=a[i];sb+=b[i]
  if a[i]>b[i]:p1+=a[i]-b[i]
  elif a[i]<b[i]:p2+=(b[i]-a[i]-1)//2+1
m=sb-sa
if m<p1 or m<p2:print("No")
else:print("Yes")

Submission status: Accepted

Solution code:
def solve(n, a, b):
    total = sum(b) - sum(a)
    num1, num2 = 0, 0
    for i in range(n):
        if a[i] > b[i]:
            num1 += a[i] - b[i]
        elif a[i] < b[i]:
            num2 += (b[i] - a[i] + 1) // 2
    return "Yes" if (total >= num1) and (total >= num2) else "No"

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

Submission status: Accepted

Solution code:
n = int(input())
a_s = [int(item) for item in input().split()]
b_s = [int(item) for item in input().split()]
num = sum(b_s) - sum(a_s)
val1 = 0
val2 = 0
for a, b in zip(a_s, b_s):
    if b > a:
        val1 += (b - a + 1) // 2
    else:
        val2 += (a-b) 
if val1 <= num and val2 <= num:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# APC001B - Two Arrays
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    A = tuple(map(int, input().split()))
    B = tuple(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")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# APC001B - Two Arrays
def main():
    n = int(input())
    arr = [tuple(map(int, input().rstrip().split())) for _ in range(2)]
    cnt = 0
    for a, b in zip(arr[0], arr[1]):
        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=tuple(map(int,input().split()))
B=tuple(map(int,input().split()))
cnt=0
for a,b in zip(A,B):
    cnt+=(max(b-a,0)+1)//2
print('Yes' if cnt<=(sum(B)-sum(A)) else 'No')

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
chance = sum(b)-sum(a)
for i in range(n):
    if a[i]<b[i]:
        chance -= (b[i]-a[i]+1)//2

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

d = 0

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

print('Yes' if d<1 else '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(b[i]-a[i])

d = 0

for i in range(n):
    if c[i]<0:
        d+=-c[i]
        c[i]=0

for i in range(n):
    d-=c[i]//2

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

Submission status: Accepted

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
t=sum(b)-sum(a)
x,y=0,0
for i in range(n):
    if a[i]<b[i]:
        x+=(b[i]-a[i]+1)//2
    else:
        y+=a[i]-b[i]
if t>=0 and x<=t and y<=t:
    ans='Yes'
else:
    ans='No'
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
cnt1=0
cnt2=0
for i in range(n):
  if arr1[i]>arr2[i]:
    cnt2+=arr1[i]-arr2[i]
  elif arr1[i]<arr2[i]:
    if (arr2[i]-arr1[i])%2==0:
      cnt1+=(arr2[i]-arr1[i])//2
    else:
      cnt1+=(arr2[i]-arr1[i])//2+1
      cnt2+=1
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()))
x=0
for i in range(n):x+=max((b[i]-a[i]+1)//2,0)
print("YNeos"[sum(b)-sum(a)<x::2])

Submission status: Accepted

Solution code:
N=int(input())

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

s=sum(b)-sum(a)

if s<0:
    print("No")
else:
    A = 2*s
    B = s
    for i in range(N):
        if a[i]-b[i]<0:
            if (a[i]-b[i])%2==0:
                A+=a[i]-b[i]
            else:
                A+=a[i]-b[i]-1
                B-=1
        else:
            B-=a[i]-b[i]
        #print(A,B)
    if A<0 or B<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()))
s,t = 0,0
for i in range(n):
    if a[i]>b[i]:
        s+=a[i]-b[i]
    else:
        t+=(b[i]-a[i])//2+(b[i]-a[i])%2
        s += (b[i] - a[i])%2
if s<=t:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
x = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
s= 0
t = 0
for i,j in zip(a,b):
    if i > j :
        s+=i-j
    if j > i :
        t+=(j - i)//2+(j-i)%2
        s+= (j-i)%2
if s<=t:
    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()]
ct1,ct2,ct3=0,0,0
for i in range(n):
  ct1+=(B[i]-A[i])
  ct2+=max(A[i]-B[i],0)
  if B[i]>A[i]:
    ct3+=(B[i]-A[i]-1)//2+1
print("Yes" if max(ct2,ct3)<=ct1 else "No")

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
count = - sum(A) + sum(B) #操作回数
inv = 0
for i in range(N):
  inv += max(0, A[i] - B[i])
  
inv2 = 0
for i in range(N):
  inv2 += max(0, (B[i] - A[i]+1)//2)
  
if count >= 0 and inv <= count and inv2 <= count:
  print("Yes")
else :
  print("No")

Submission status: Accepted

Solution code:
n=int(input())
*A,=map(int,input().split())
*B,=map(int,input().split())
print("Yes" if sum(B)-sum(A) >= sum(max((a+b)%2,a-b) for a,b in zip(A,B)) 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)
ca = 0
cb = 0

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

if cnt >= max(ca,cb):
    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,q = 0,0
for i in range(n):
    if a[i] > b[i]:
        q += a[i]-b[i]
    else:
        p += (b[i]-a[i])//2
if p >= q:
    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, 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())
lia=[int(it) for it in input().split()]
lib=[int(it) for it in input().split()]
lip=[lia[i]-lib[i] for i in range(N)]
sb = 0
for i in range(N):
  if (lip[i]>0):
    sb+=lip[i]
sa2 = 0
for i in range(N):
  if (lip[i]<0):
    sa2+=(-lip[i])//2
x = sum(lib)-sum(lia)
if (x<0):
  print ("No")
else:
  if (sa2>=sb):
    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()))

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

if diff <= chance:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

suma = sum(alist)
sumb = sum(blist)

ac, bc = 0, 0
for a, b in zip(alist, blist):
  if a < b:
    ac += (b - a) // 2 + (1 if (b - a) % 2 == 1 else 0)
  elif a > b:
    bc += a - b
if max(ac, bc) <= sumb - suma:
  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()))
dif = list(x-y for x,y in zip(a,b))
cnt = 0
for d in dif:
    if d>0:
        cnt += d
    else:
        cnt += math.ceil(d/2)
if cnt <= 0:
    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()))
c = [i-j for i,j in zip(a,b)]
plus = 0
minus = 0
for i in c:
  if i >= 0:
    plus += i
  else:
    minus += math.ceil(i / 2)
print("Yes") if abs(minus) >= plus else print("No")

Submission status: Accepted

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

Submission status: Accepted

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

x = sum(B)-sum(A)
if x<0:
  #print(sum(B), sum(A), x)
  print('No')
  exit()
  
C = [b-a for a, b in zip(A,B)]
#a
if sum([(c+1)//2 if c>0 else 0 for c in C]) >x:
  #print(C)
  #print([(c+1)//2 if c>0 else 0 for c in C])
  print('No')
  exit()

#b
if sum([-c if c<=0 else c%2 for c in C]) >x:
  #print('b')
  #print(C)
  #print([-c if c<=0 else c%2 for c in C])
  print('No')
  exit()
print('Yes')

Submission status: Accepted

Solution code:
import sys


fin = sys.stdin.readline
N = int(fin())
a_list = [int(elem) for elem in fin().split()]
b_list = [int(elem) for elem in fin().split()]
sum_diff = sum(b_list) - sum(a_list)
if sum_diff < 0:
    print("No")
    exit(0)

diffs = [b - a for a, b in zip(a_list, b_list) if b - a > 0]

num_ops = 0
for diff in diffs:
    num_ops += (diff + 1) // 2

if num_ops > sum_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()))

K = sum(b) - sum(a)
oneplus = 0
twoplus = 0
for i in range(N):
    if a[i] > b[i]:
        oneplus += a[i] - b[i]
    elif a[i] < b[i]:
        twoplus += (b[i]-a[i]+1)//2

if oneplus <= K and twoplus <= K:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

t=sum(B)-sum(A)
if t==0:
    if A==B: print("Yes")
    else: print("No")
elif t<0: print("No")
else:
    pa=0
    pb=0
    for a,b in zip(A,B):
        if a==b: continue
        if a>b: pb+=(a-b)
        else:
            if (b-a)%2==0: pa+=(b-a)//2
            else:
                pa+=(b-a+1)//2
                pb+=1
    if pa>t or pb>t: print("No")
    else: print("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()]
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:
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    n = int(input())
    aa = list(map(int, input().split()))
    bb = list(map(int, input().split()))

    turn = sum(bb)-sum(aa)
    for a, b in zip(aa, bb):
        turn -= max([0,b-a+1])//2
    if turn < 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()))

suma = sum(A)
sumb = sum(B)

if all( A[i] == B[i] for i in range(N)):
    print("Yes")
    exit()
if all( A[i] <= B[i] for i in range(N)):
    print("Yes")
    exit()    
if suma >= sumb:
    print("No")
    exit()
margin = 0
ato = 0
for i in range(N):
    if A[i] < B[i]:
        margin += (B[i] - A[i])//2 * 2
    if A[i] > B[i]:
        ato += A[i] - B[i]

if margin >= 2 * ato:
    print("Yes")
    exit()
print("No")

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
t = [0]*n
for i in range(n):
  t[i] = b[i]-a[i]
tot = sum(t)
k = 0
for x in t:
  if x > 0:
    k += (x-1)//2 + 1
if k <= tot:
  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()))
p1=0
p2=0
for i in range(n):
    a=A[i]
    b=B[i]
    if(a%2!=b%2):
        p1+=1
        b+=1
    if(a>b):
        p1+=a-b
    elif(a<b):
        p2+=(b-a)//2
if(p2>=p1):
    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()))
sousa = sum(b) - sum(a)
if sousa < 0:
    print('No')
    exit()
if sousa == 0:
    if a == b:
        print('Yes')
    else:
        print('No')
    exit()
p, q = 0, 0
for i, j in zip(a, b):
    if i > j:
        q += i - j
    if i < j:
        if (i - j) % 2 == 0:
            p += (j - i) // 2
        else:
            p += (j - i) // 2 + 1
            q += 1
# print(p, q, sousa)
if (sousa >= p) and (sousa >= q) and (sousa - p) * 2 == (sousa - q):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import math
N = int(input())
L = list(map(int,input().split()))
M = list(map(int,input().split()))
cnt = 0
for i in range(N):
  if L[i] < M[i]:
    cnt += math.ceil((M[i]-L[i])/2)
if cnt <= sum(M)-sum(L):
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

x=y=0
for i,j in zip(a,b):
    if i>j:x+=i-j
    else:y+=(j-i)//2
if y>=x:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

a_b = 0
b_a = 0
for i in range(N):
    if A[i] > B[i]:
        a_b += A[i] - B[i]
        
    else:
        b_a += (B[i] - A[i]) // 2

if a_b <= b_a:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N=int(input())
import sys
input=sys.stdin.readline

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

A=0
B=0
for i in range(N):
    if a[i]==b[i]:
        pass
    elif a[i]>b[i]:
        B+=a[i]-b[i]
    else:
        if (b[i]-a[i])%2==1:
            A+=b[i]-a[i]+1
            B+=1
        else:
            A+=b[i]-a[i]
if A<B*2:
    print("No")
else:
    print("Yes")
#print(A,B)

Submission status: Accepted

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

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians, log10
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul, xor
from copy import copy, deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits
from datetime import date

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
A=LIST()
B=LIST()

cnt1=cnt2=0
for i in range(N):
    if A[i]>B[i]:
        # Bのが少ない合計*2(この分Aのどっかに足さないといけない)
        cnt1+=(A[i]-B[i])*2
    elif A[i]<B[i]:
        # Aのが少ない合計(この分で上記cnt1を受けきれるかどうか)
        # (こっちの合計が多い分には、同じ所でひたすら操作すれば帳尻が合うのでOK)
        # (同じ場所に2ないと意味ないので、1余る部分は数えない)
        cnt2+=(B[i]-A[i])-(B[i]-A[i])%2
if cnt1<=cnt2:
    Yes()
else:
    No()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math


def solve(N, As, Bs):
    sa = sum(As)
    sb = sum(Bs)
    if sa > sb:
        return "No"
    splus = sum([math.ceil((b - a) / 2) for a, b in zip(As, Bs) if b - a >= 0])
    if sa + splus > sb:
        return "No"
    else:
        return "Yes"

if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split(" ")))
    Bs = list(map(int, input().split(" ")))
    print(solve(N, As, Bs))

Submission status: Accepted

Solution code:
n =int(input())
a = list(int(i) for i in input().split())
b = list(int(i) for i in input().split())
ans = 'Yes'
ct =0
ct2 = 0
kaisuu = 0
if sum(a) > sum(b) :
  ans = 'No'
elif sum(a) == sum(b) and a != b:
  ans ='No'
else:
  kaisuu = sum(b)-sum(a)
  for i in range(n):
   if a[i] >= b[i]:
    ct += a[i]-b[i]
   else:
    ct2 += (b[i]-a[i]+1)//2
if ct <= kaisuu and ct2 <= kaisuu:
  pass
else:
  ans = 'No'
  
  
print(ans)

Submission status: Accepted

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

a_cnt = 0
b_cnt = 0

for i in range(N):
    a = a_list[i]
    b = b_list[i]

    if a == b:
        continue
    elif a > b:
        a_cnt += a - b

    else:
        b_cnt += (b - a + 1) // 2
tmp = sum(b_list) - sum(a_list)
if a_cnt <= tmp and b_cnt <= tmp:
    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 a,b in zip(A,B) :
    if a < b :
        if (b-a) % 2 == 0 :
            p += b-a
        else :
            p += b-a-1
    else :
        p -= (a-b)*2

if p >= 0 :
    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()))
c=0
for i in range(n):
  if a[i]<b[i]:c+=((b[i]-a[i]+1)//2)
if c>sum(b)-sum(a):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 = list(map(lambda x, y: x-y, A, B))

C_neg = list(filter(lambda x: x < 0, C))
C_pos = list(filter(lambda x: x > 0, C))
len_odd_neg = len(list(filter(lambda x: x % 2 == 1, C_neg)))
pos_sum = sum(C_pos)
neg_sum = sum(C_neg)+len_odd_neg

if pos_sum <= abs(neg_sum)//2:
    ans = "Yes"
else:
    ans = "No"
print(ans)

Submission status: Accepted

Solution code:
N2 = int(input())

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

P = 0
N = 0

for i in range(N2):
    if b[i]-a[i]>=0:
        P = P + ((b[i]-a[i])//2)*2
    else:
        N = N + a[i]-b[i]
       
P2 = P-2*N
        
if P2>=0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys


def next_str() -> str:
    result = ""
    while True:
        next_chr = sys.stdin.read(1)
        if next_chr.strip() != "":
            result += next_chr
        elif next_chr != '\r':
            break
    return result


def next_int() -> int:
    return int(next_str())


n = next_int()
A = [next_int() for i in range(n)]
B = [next_int() for i in range(n)]

savings = 0


def main() -> None:
    global savings
    for i in range(n):
        c = B[i] - A[i]
        if c > 0:
            savings += c // 2
        else:
            savings += c

    print(["Yes", "No"][savings < 0])


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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]
  else:
    v += (b[i] - a[i]) // 2
if u > v:
  print("No")
else:
  print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
A = [int(_) for _ in input().split()]
B = [int(_) for _ in input().split()]
diff = 0
for i in range(N):
    x = A[i] - B[i]
    if x > 0:
        diff += 2 * x
    else:
        diff -= 2 * (-x // 2)
if diff <= 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))

numA, numB = 0, 0
for A, B in zip(As, Bs):
    if A < B:
        numA += (B - A + 1) // 2
        A += (B - A + 1) // 2 * 2
    if A > B:
        numB += A - B

if numA >= numB:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))

numOpe = sum(Bs) - sum(As)

numA, numB = 0, 0
for A, B in zip(As, Bs):
    if A < B:
        numA += (B - A + 1) // 2
    elif A > B:
        numB += A - B

if numA <= numOpe and numB <= numOpe:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def inpl(): return [int(i) for i in input().split()]
N = int(input())
A = inpl()
B = inpl()
M = sum(B)-sum(A)
ans = 'Yes'
if M < 0:
    ans = 'No'
ca, cb = 0, 0
for i in range(N):
    dba = B[i] - A[i]
    if dba > 0:
        ca += -(-dba//2)
        cb += dba%2
    else:
        cb -= dba
if M != 2*ca-cb or ca > M:
    ans = 'No'
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

p1 = 0
p2 = 0
ng = 0
for i in range(n):
    if b[i]>=a[i]:
        p1 += (b[i]-a[i])//2
        p2 += (b[i]-a[i])%2
    else:
        ng += a[i]-b[i]

if p1>=ng:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

total = sum(B) - sum(A)
Aadd = 0
for i in range(N):
    if A[i] < B[i]:
        if (B[i] - A[i])%2==0:
            Aadd += (B[i]-A[i])//2
        else:
            Aadd += (B[i]-A[i])//2+1
print("Yes" if Aadd <= total 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()]

cnt = [0,0]
for ai, bi in zip(a, b):
    if ai < bi:
        cnt[0] += (bi - ai) // 2
    elif ai > bi:
        cnt[1] += ai - bi

if cnt[0] < cnt[1]:
    print("No")
    exit()

if sum(b)-sum(a) >= 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()))
x = 0
for i in range(n):
    if a[i] < b[i]:
        x += (b[i] - a[i])//2
    else:
        x -= (a[i] - b[i])
if x < 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()))
x = 0
for i in range(n):
    if a[i] < b[i]:
        x += (b[i] - a[i])//2
    else:
        x -= (a[i] - b[i])
if x < 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()))
s,t=0,0
for i,j in zip(a,b):
    if i>j:t+=i-j
    else:s+=(j-i)//2
if s>=t: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 = sum(B) - sum(A)
cnta = 0
cntb = 0
for i in range(N):
    a = A[i]
    if A[i] == B[i]:
        pass
    elif A[i] > B[i]:
        cntb += A[i]-B[i]
    else:
        if (B[i]-A[i])%2 == 1:
            cnta += 1
            cntb += 1
        cnta += (B[i]-A[i])//2
if cnt <= -1:
    print('No')
elif cnt >= cnta and cnt >=  cntb and cnt - cntb == 2*(cnt - cnta):
    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 = sum(b) - sum(a)
d,e = 0,0
for i,j in zip(a,b):
    if i>j:
        d += i-j
    elif i<j:
        d += (j-i)%2
        e += (j-i+1)//2
if c < max(d,e):
    print('No')
else:
    if 2*d-e<=c:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
n = int(input())
list_a = list(map(int, input().split()))
list_b = list(map(int, input().split()))
list_a_memo = []
list_b_memo = []
for i in range(n):
    if list_a[i] == list_b[i]:
        list_a_memo.append(0)
        list_b_memo.append(0)
    elif list_a[i] > list_b[i]:
        list_a_memo.append(0)
        list_b_memo.append(list_a[i] - list_b[i])
    else:
        list_a_memo.append((list_b[i] - list_a[i]) // 2)
sum_a = sum(list_a_memo)
sum_b = sum(list_b_memo)
if sum_a >= sum_b:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
a = map(int, input().split())
b = map(int, input().split())
ca, cb = 0, 0
for i, j in zip(a, b):
    if i > j:
        cb += i - j
    else:
        ca += (j - i) // 2
if ca >= cb:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

negatives = 0
positives = 0

for aa, bb in zip(a,b):
    if aa - bb < 0:
        negatives += (bb-aa)//2*2
    else:
        positives += aa-bb

if negatives >= 2*positives:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
ai = lambda: list(map(int, input().split()))

n = int(input())
a = ai()
b = ai()
d = [b[i] - a[i] for i in range(n)]
s,t = 0,0
for i in d:
    if i > 0:
        s += -(-i//2)
        t += i%2
    else:
        t += -i
if s<t:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
def iin(): return int(input())
def nl(): return list(map(int, input().split()))

n = iin()
a = nl()
b = nl()

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

Submission status: Accepted

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

time = sum(b) - sum(a)
if time < 0:
	print("No")
else:
	pos = 0
	neg = 0
	for i in range(n):
		if a[i] <= b[i]:
			pos += (b[i] - a[i] + 1) // 2
		else:
			neg += a[i] - b[i]
	if pos <= time and neg <= time:
		print("Yes")
	else:
		print("No")

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N = inp()
aa = inpl()
bb = inpl()

tmp1 = 0
tmp2 = 0
for i in range(N):
	a,b = aa[i],bb[i]
	if a < b:
		tmp1 += (b-a)//2
	else:
		tmp2 += a-b

if tmp2 <= tmp1:
	print('Yes')
else:
	print('No')

Submission status: Accepted

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

# 可能操作回数
op = sum(b) - sum(a)

# 必要操作回数のカウント
a_must = 0
b_must = 0
for ai, bi in zip(a,b):
    if ai  > bi:
        b_must += (ai - bi)
    
    elif bi > ai:
        a_must += (bi - ai +1) // 2
        b_must += (bi - ai) % 2
    

# 可能回数と比較して、可能ならYes
if a_must <= op and b_must <= op:
    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())

a_t = 0
b_t = 0

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

	else:
		b_t += (b[i]-a[i])/2

print 'Yes' if a_t <= b_t else 'No'

Submission status: Accepted

Solution code:

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


    Flag = False
    biga = 0
    lessa = 0
    for i in range(n):
        if a[i] > b[i]:
            biga += a[i] - b[i]
        else:
            lessa += (b[i] - a[i]) //2

    tmp = lessa - biga

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
d = sum(B) - sum(A)
for i in range(N):
  if A[i] % 2 != B[i] % 2:
    B[i] += 1
    d -= 1
print('Yes' if sum([max(A[i] - B[i], 0) for i in range(N)]) <= d else 'No')