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: Wrong Answer

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]
    
if B_A < 2*A_B and not (A_B == 0 and B_A == 0):
  print('No')
else:
  print('Yes')

Submission status: Wrong Answer

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]
    
if B_A < 2*A_B:
  print('No')
else:
  print('Yes')

Submission status: Wrong Answer

Solution code:

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

    cnt = sum(B) - sum(A)
    for i in range(N):
        if A[i] > B[i]:
            cnt -= A[i] - B[i]
        elif A[i] < B[i]:
            cnt -= (B[i] - A[i]) // 2

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


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cnt1=[0]*n
cnt2=[0]*n
for i in range(n):
    if a[i]>b[i]:
        cnt2[i]=a[i]-b[i]
    else:
        num4=b[i]-a[i]
        cnt1[i]=num4//2
        cnt2[i]=num4%2
num5=abs(sum(a)-sum(b))
if max(sum(cnt1),sum(cnt2))+abs(sum(cnt1)-sum(cnt2))<=num5:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cnt1=[0]*n
cnt2=[0]*n
for i in range(n):
    if a[i]>b[i]:
        cnt2[i]=a[i]-b[i]
    else:
        num4=b[i]-a[i]
        cnt1[i]=num4//2
        cnt2[i]=num4%2
num5=abs(sum(a)-sum(b))
if max(sum(cnt1),sum(cnt2))+abs(sum(cnt1)-sum(cnt2))==num5:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cnt1=[0]*n
cnt2=[0]*n
for i in range(n):
    if a[i]>b[i]:
        cnt2[i]=a[i]-b[i]
    else:
        num4=b[i]-a[i]
        cnt1[i]=num4//2
        cnt2[i]=num4%2
num5=abs(sum(a)-sum(b))
if sum(cnt1)<=num5 and sum(cnt2)<=num5 and (sum(cnt2)-sum(cnt1))%2==0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cnt1=[0]*n
cnt2=[0]*n
for i in range(n):
    if a[i]>b[i]:
        cnt2[i]=a[i]-b[i]
    else:
        num4=b[i]-a[i]
        cnt1[i]=num4//2
        cnt2[i]=num4%2
num5=abs(sum(a)-sum(b))
if sum(cnt1)<sum(cnt2):
    if sum(cnt1)<=num5 and sum(cnt2)<=num5 and (sum(cnt2)-sum(cnt1))%2==0:
        print("Yes")
    else:
        print("No")
else:
    if sum(cnt1)<=num5 and sum(cnt2)<=num5:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cnt1=[0]*n
cnt2=[0]*n
for i in range(n):
    if a[i]>b[i]:
        cnt2[i]=a[i]-b[i]
    else:
        num4=b[i]-a[i]
        cnt1[i]=num4//2
        cnt2[i]=num4%2
num5=abs(sum(a)-sum(b))
if sum(cnt1)<=num5 and sum(cnt2)<=num5:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

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

gap = sum(A)-sum(B)
if gap + count*2 > 0:
  print('No')
elif gap + count*2 == 0 and sum([(B[i]-A[i])%2 for i in range(N)])>0:
  print('No')
else:
  print('Yes')

Submission status: Wrong Answer

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

count=0
for i in range(N):
  if B[i]<A[i]:
    count += A[i]-B[i]
    B[i] = A[i]
    
gap = sum(A)-sum(B)
if gap + count*2 > 0:
  print('No')
else:
  print('Yes')

Submission status: Wrong Answer

Solution code:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
sa=sum(a)
sb=sum(b)
if sb<sa:
    print("No")
else:
    cnt=sb-sa
    resa=0
    resb=0
    for i in range(n):
        if b[i]<a[i]:
            resa+=a[i]-b[i]
        else:
            resb+=math.ceil((b[i]-a[i])/2)
    if resa+resb>cnt:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
sa=sum(a)
sb=sum(b)
if sb<sa:
    print("No")
else:
    cnt=sb-sa
    resa=0
    resb=0
    for i in range(n):
        if b[i]<a[i]:
            resa+=a[i]-b[i]
        else:
            resb+=b[i]-a[i]
    if resa+resb/2>=cnt:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
sa=sum(a)
sb=sum(b)
if sb<sa:
    print("No")
else:
    cnt=sb-sa
    resa=0
    resb=0
    for i in range(n):
        if b[i]<a[i]:
            resa+=a[i]-b[i]
        else:
            resb+=b[i]-a[i]
    if resa+resb/2>cnt:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
sa=sum(a)
sb=sum(b)
if sb<sa:
    print("No")
else:
    cnt=sb-sa
    resa=0
    resb=0
    for i in range(n):
        if b[i]<a[i]:
            resa+=a[i]-b[i]
        else:
            resb+=b[i]-a[i]
    if resa>cnt:
        print("No")
    elif resb/2>cnt:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
sa=sum(a)
sb=sum(b)
if sb<sa:
    print("No")
else:
    cnt=sb-sa
    res=0
    for i in range(n):
        if b[i]<a[i]:
            res+=a[i]-b[i]
    if res>cnt:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[int(x) for x in input().split()]
B=[int(x) for x in input().split()]
C=[y-x for x,y in zip(A,B)]
C_posi=[x for x in C if x>=0]
C_neg=[x for x in C if x<0]
if sum(C)>=0 and sum(C_posi)<=sum(C)*2:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[int(x) for x in input().split()]
B=[int(x) for x in input().split()]
C=[x-y for x,y in zip(A,B)]
C_posi=[x for x in C if x>=0]
C_neg=[x for x in C if x<0]
if sum(C)>=0 and sum(C_posi)<=sum(C)*2:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

Aup = 0
Bup = 0
for i in range(n):
    tmp = A[i] - B[i]
    if tmp <= 0:
        Aup += abs(tmp)
    else:
        Bup += tmp

Bup -= Aup//2
Aup -= (Aup//2)*2

#print(Aup)
#print(Bup)

if not Aup:
    if not Bup:
        print('Yes')
    elif Bup > 0:
        print('No')
    else:
        print('Yes')
else:
    if not Bup:
        print('Yes')
    elif Bup > 0:
        if Bup == 1:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

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

Aup = 0
Bup = 0
for i in range(n):
    tmp = A[i] - B[i]
    if tmp <= 0:
        Aup += abs(tmp)
    else:
        Bup += tmp

Bup -= Aup//2
Aup -= (Aup//2)*2

print(Aup)
print(Bup)

if not Aup:
    if not Bup:
        print('Yes')
    elif Bup > 0:
        print('No')
    else:
        print('Yes')
else:
    if not Bup:
        print('Yes')
    elif Bup > 0:
        if Bup == 1:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

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

Aup = 0
Bup = 0
for i in range(n):
    tmp = A[i] - B[i]
    if tmp <= 0:
        Aup += abs(tmp)
    else:
        Bup += tmp

Bup -= Aup//2
Aup -= (Aup//2)*2

if not Aup:
    if not Bup:
        print('Yes')
    elif Bup > 0:
        print('No')
    else:
        print('Yes')
else:
    if not Bup:
        print('Yes')
    elif Bup > 0:
        print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

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

Aup = 0
Bup = 0
for i in range(n):
    tmp = A[i] - B[i]
    if tmp <= 0:
        Aup += abs(tmp)
    else:
        Bup += tmp

Bup -= Aup//2
Aup -= (Aup//2)*2

if not Aup:
    if not Bup:
        print('Yes')
    elif Bup > 0:
        print('No')
    else:
        if Bup%2 == 0:
            print('No')
        else:
            print('Yes')
else:
    if not Bup:
        print('Yes')
    elif Bup > 0:
        print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

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

Aup = 0
Bup = 0
for i in range(n):
    tmp = A[i] - B[i]
    if tmp <= 0:
        Aup += abs(tmp)
    else:
        Bup += tmp

Bup -= Aup//2
Aup -= (Aup//2)*2

if not Aup:
    if not Bup:
        print('Yes')
    elif Bup > 0:
        print('No')
    else:
        if Bup%2 == 0:
            print('No')
        else:
            print('Yes')
else:
    if not Bup:
        print('Yes')
    elif Bup > 0:
        print('No')
    else:
        if Bup%2:
            print('Yes')
        else:
            print('No')

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    D = [a - b for a, b in zip(A, B)]
    # [0, 0, ..., 0]の数列に対し、「どれかを-2」「どれかを+1」をN回ずつやってDを作れるか？
    cnt_m2 = 0
    cnt_p1 = 0
    # 必要最低限な個数を計算
    for d in D:
        if d < 0:
            if d % 2 == 0:
                cnt_m2 += abs(d) // 2
            else:
                cnt_m2 += (abs(d) + 1) // 2
                cnt_p1 += 1
        if d > 0:
            cnt_p1 += d
    if cnt_m2 > N or cnt_p1 > N:
        print('No')
    else:
        # 余った分については、「-2の回数」:「+1の回数」=1:2 なら相殺可能。
        # そうでなければ相殺不可能。
        if (N - cnt_m2) * 2 == (N - cnt_p1):
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

capacity=0
for i in range(n):
    capacity+=max(0,b[i]-a[i])

for i in range(n):
    if a[i]>b[i]:
        capacity-=(a[i]-b[i])*2

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

Submission status: Wrong Answer

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

x = sum(B)-sum(A)

one = 0
two = 0

for i in range(N):
    if A[i] > B[i]:
        one += A[i]-B[i]
    if A[i] < B[i]:
        two += (B[i]-A[i])//2

if one<=x and two<=x:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

A.sort()
B.sort()

i = 0
j = 0
while i<N and j<N:
    while j<N:
        if A[j]%2 != B[j]%2:
            B[j] += 1
            break
        elif A[i] > B[j]:
            B[j] += 1
            break
        else:
            j += 1

    while i<N:
        if A[i] < B[i]:
            A[i] += 2
            break
        else:
            i += 1
    
    i += 1
    j += 1

if i>=N and j>=N and A[-1] == B[-1]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# coding: utf-8
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
sa=sum(A)
sb=sum(B)
#print(sa)
#print(sb)
flg=True
if sa >= sb:
    flg=False
else:
    if (sb-sa)%2==0:
        flg=False
if flg:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
sum_diffA = 0
sum_diffB = 0
for i, (ai, bi) in enumerate(zip(A,B)):
    diffA = max(bi-ai, 0)
    sum_diffA += diffA
    if diffA == 1:
        sum_diffB += 1
    else:
        sum_diffB += max(ai-bi, 0)
if sum_diffA // 2 >= sum_diffB:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
sum_diffA = 0
sum_diffB = 0
for i, (ai, bi) in enumerate(zip(A,B)):
    sum_diffA += max(bi-ai, 0)
    sum_diffB += max(ai-bi, 0)
if sum_diffA // 2 >= sum_diffB:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
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()

A=[0]*N
B=[0]*N

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

if sum(A)>n or sum(B)>n:
    print("No")
    exit()

if (n-sum(A))*2==n-sum(B):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

if n == 1:
    if a[0] <= b[0]:
        print('Yes')
    else:
        print('No')
    sys.exit()

for i, j in zip(a, b):
    num = j-i
    if num == 1:
        continue
    elif num >= 0:
        plus += num
    else:
        minus -= num
        
if plus >= minus*2:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

if n == 1:
    if a[0] <= b[0]:
        print('Yes')
    else:
        print('No')
    sys.exit()

for i, j in zip(a, b):
    num = j-i
    if num >= 0:
        plus += num
    else:
        minus -= num
        
if plus > minus*2:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

if n == 1:
    if a[0] <= b[0]:
        print('Yes')
    else:
        print('No')
    sys.exit()

for i, j in zip(a, b):
    num = j-i
    if num >= 0:
        plus += num
    else:
        minus -= num
        
if plus >= minus*2:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

if n == 1:
    if a[0] < b[0]:
        print('Yes')
    else:
        print('No')
    sys.exit()

for i, j in zip(a, b):
    num = j-i
    if num >= 0:
        plus += num
    else:
        minus -= num
        
if plus >= minus*2:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

for i, j in zip(a, b):
    num = j-i
    if num >= 0:
        plus += num
    else:
        minus -= num
        
if plus >= minus*2:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
a_sum = 0
b_sum = 0
for i in range(n):
    c.append(b[i]-a[i])
    if c[i] < 0:
        b_sum += c[i]//2
    else:
        a_sum += c[i]

if a_sum < abs(b_sum):
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
a_sum = 0
b_sum = 0
for i in range(n):
    c.append(b[i]-a[i])
    if c[i] < 0:
        b_sum += c[i]
    else:
        a_sum += c[i]

if a_sum <= abs(b_sum*2):
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
a_sum = 0
b_sum = 0
for i in range(n):
    c.append(b[i]-a[i])
    if c[i] < 0:
        b_sum += c[i]
    else:
        a_sum += c[i]

if a_sum < abs(b_sum*2):
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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()))
    CNT = 0
    for i in range(N):
        a = A[i]
        b = B[i]
        if a > b:
            CNT += a-b
        elif a < b:
            CNT += (b-a+1)// 2
    sa = sum(A)
    sb = sum(B)
    if sa > sb:
        print('No')
    elif sb - sa >= CNT:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [b[i] - a[i] for i in range(n)]
print("Yes" if sum(a) < sum(b) and sum(c)%2 else "No")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from collections import Counter

def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    B = list(map(int, input().strip().split()))
    return N, A, B


def solve(N, A, B):
    p, m = 0, 0
    for a, b in zip(A, B):
        d = b - a
        if d > 0:
            p += d
        elif d < 0:
            m += d
    return "Yes" if p + 2 * m >= 0 else "No"


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque, defaultdict
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N = II()
    A = LI()
    B = LI()

    a = sum(A)
    b = sum(B)
    t = b - a
    if t < 0:
        print('No')
        return 
    a_cnt = 0
    b_cnt = 0
    for i in range(N):
        a = A[i]
        b = B[i]
        if a > b:
            c = a - b
            b_cnt += c
        elif a < b:
            c = b - a
            if c % 2 == 0:
                a_cnt += (c // 2)
            else:
                print('No')
                return
    # print(a_cnt, b_cnt, t - a_cnt, t - b_cnt)
    a_left = t - a_cnt
    b_left = t - b_cnt
    if a_left * 2 == b_left:
        print('Yes')

                
            

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

K=sum(B)-sum(A)

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

Submission status: Wrong Answer

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

p, m, cnt = 0, 0, 0
for i in range(N):
  if a[i]-b[i] >= 0:
    p += a[i]-b[i]
  else:
    m += b[i]-a[i]
    cnt += 1
    
if (2*p<=m) and (cnt<=p):
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

p, m = 0, 0
for i in range(N):
  if a[i]-b[i] > 0:
    p += a[i]-b[i]
  else:
    m += b[i]-a[i]
    
if 2*p <= m:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ca = 0
cb = 0
for aa, bb in zip(a, b):
    if aa < bb:
        cb += (bb - aa)//2
    if bb < aa:
        ca += aa - bb
# print(ca, cb)
if cb <= ca:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ca = 0
cb = 0
for aa, bb in zip(a, b):
    if aa < bb:
        cb += (bb - aa)//2
    if bb < aa:
        ca += aa - bb
# print(ca, cb)
if cb <= aa:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ca = 0
cb = 0
for aa, bb in zip(a, b):
    if aa < bb:
        ca += (bb - aa)//2
    if bb < aa:
        cb += aa - bb
# print(ca, cb)
if cb <= aa:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
A = list(map(int, sys.stdin.readline().rsplit()))
B = list(map(int, sys.stdin.readline().rsplit()))

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

if b >= a:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

K=sum(B)-sum(A)

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

Submission status: Wrong Answer

Solution code:
N = int(input())

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

total1 = 0
total2 = 0

for i in range(N):
    if a[i]>b[i]:
        total1 += a[i]-b[i]
    else:
        total2 += b[i]-a[i]

if total1 <=total2//2:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())

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

total1 = 0
total2 = 0

for i in range(N):
    if a[i]>b[i]:
        total1 += a[i]-b[i]
    else:
        total2 += b[i]-a[i]

if total1 <=round(total2/2):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())

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

total1 = 0
total2 = 0

for i in range(N):
    if a[i]>b[i]:
        total1 += a[i]-b[i]
    else:
        total2 += b[i]-a[i]

if total1 <=total2/2:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))+[float("inf")]
B=list(map(int,input().split()))+[-float("inf")]

A.sort()
B.sort(reverse=True)

k=0
while A[k]<B[k]:
    k+=1

M=0
for i in range(k):
    M+=(B[i]-A[i])//2

for i in range(k,N):
    M-=A[i]-B[i]

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

Submission status: Wrong Answer

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

p=q=0
for i in range(n):
    if A[i]<B[i]:
        p+=(B[i]-A[i])//2
    else:
        q=A[i]-B[i]
if p==q:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


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

    cnt = 0
    for x, y in zip(a, b):
        diff = x - y
        if diff < 0:
            cnt += abs(diff) // 2

    for x, y in zip(a, b):
        diff = x - y
        if diff > 0:
            cnt -= diff

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


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

    cnt = sum(b) - sum(a)

    i = 0

    while i < n - 1:
        diff = a[i] - b[i]
        if diff < 0:
            if diff % 2 == 1:
                b[i] += 1
                a[i] += abs(diff) + 1
            else:
                a[i] += abs(diff)
                b[i + 1] += abs(diff) // 2
        elif diff > 0:
            b[i] += diff
            a[i + 1] += 2 * diff
        i += 1

    if a[n - 1] <= b[n - 1]:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


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

    cnt = sum(b) - sum(a)
    c = [x - y for x, y in zip(a, b)]
    neg = - sum(x for x in c if x < 0)
    pos = sum(x for x in c if x > 0)

    if neg > cnt * 2 or pos > cnt:
        print("No")
    else:
        print("Yes")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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: Wrong Answer

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)

if suma>=sumb:
    print("No")
    exit()

#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)

if cntb<=k and cnta<=k:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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)

if suma>=sumb:
    print("No")
    exit()

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

k=suma-sumb
#
#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)

if cntb<=k and cnta<=k:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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)

if suma>=sumb:
    print("No")
    exit()

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

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

cnta=0
cntb=0
for i in range(n):
    if a[i]>b[i]:
        cntb+=b[i]-a[i]
    elif a[i]<b[i]:
        cnta+=(-1)*((a[i]-b[i])//2)

if cntb<=k and cnta<=k:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())

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

a.sort()
b.sort()


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



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

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


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

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