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:
import math
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
sum_A = sum(A)
sum_B = sum(B)
cnt1 = sum_B - sum_A
cnt2 = 0
for a, b in zip(A, B):
    if a > b:
        cnt2 += a - b
    elif a < b:
        cnt2 += math.ceil((b - a) / 2)
if cnt1 < cnt2:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
sum_A = sum(A)
sum_B = sum(B)
cnt1 = sum_B - sum_A
cnt2 = 0
for a, b in zip(A, B):
    if a > b:
        cnt2 += a - b
    elif b < a:
        cnt2 += math.ceil((b - a) / 2)
if cnt1 < cnt2:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, a: "List[int]", b: "List[int]"):
    A_sum = sum(a)
    B_sum = sum(b)
    if A_sum > B_sum:
        print(NO)
        return
    
    dif = [a[i]-b[i] for i in range(N)]
    one = 0
    for i in range(N):
        if dif[i] > 0:
            one += dif[i]
    
    if one > B_sum-A_sum:
        print(NO)
    else:
        print(YES)
    # minimum_operations = []

    # for i in range(N):
    #     if dif[i] >= 0:
    #         minimum_operations.append(dif[i])
    #     else:
    #         minimum_operations.append(-(dif[i]//2))

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    b = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a, b)

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

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

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

sum_minus=0
sum_plus=0
for i in range(n):
    sub = a[i] - b[i]
    if sub < 0:
        sum_minus+=sub
    else:
        sum_plus+=sub

kaisuu = -(sum_minus+sum_plus)
nokori = kaisuu - sum_plus

if nokori < 0:
    print("No")
    exit()

if kaisuu*2 - nokori == -sum_minus:
    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()))

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

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

sum_minus=0
sum_plus=0
for i in range(n):
    sub = a[i] - b[i]
    if sub < 0:
        sum_minus+=sub
    else:
        sum_plus+=sub

sm = sum_minus+sum_plus

if -sm < sum_plus:
    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()))
if sum(a) > sum(b):
    print('No')
elif a == b:
    print('Yes')
else:
    count = 0
    diff = 0
    for ai,bi in zip(a,b):
        if ai == bi:
            continue
        elif ai < bi:
            diff += (bi-ai)//2
            continue
        else:
            count += 2*(ai-bi)
    if diff >= count:
        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()))
if sum(a) > sum(b):
    print('No')
elif a == b:
    print('Yes')
elif sum(a) == sum(b):
    print('No')
else:
    count = 0
    diff = 0
    for ai,bi in zip(a,b):
        if ai == bi:
            continue
        elif ai < bi:
            diff += (bi-ai)//2
            continue
        else:
            count += 2*(ai-bi)
    if diff >= count:
        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()))
if sum(a) > sum(b):
    print('No')
elif a == b:
    print('Yes')
elif sum(a) == sum(b):
    print('No')
else:
    count = 0
    diff = 0
    for ai,bi in zip(a,b):
        if ai == bi:
            continue
        elif ai < bi:
            diff += bi-ai
            continue
        else:
            count += 2*(ai-bi)
    if diff >= count:
        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 = sum([b[i]-a[i]for i in range(n)])
if c==sum([max(a[i]-b[i], (b[i]-a[i])/2)for i in range(n)]):
    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 = sum([b[i]-a[i]for i in range(n)])
i = 0
while i<50:
    if bin(c+i).count("1")==i:
        print("Yes")
        break
    i += 1
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 = sum([b[i]-a[i]for i in range(n)])
i = 0
while i<50:
    if bin(c+i).count("1")==i:
        print(i)
        print("Yes")
        break
    i += 1
else: print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin
n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))
b = list(map(int,stdin.readline().rstrip().split()))
A = sum(a);B = sum(b)
count = 0
total = B-A
for i,j in zip(a,b):
    if i < j:
        count += (j-i+1)//2
    else:
        count += i-j
if count <= total:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin
n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))
b = list(map(int,stdin.readline().rstrip().split()))
su = 0
for i,j in zip(a,b):
    if j-i > 0:
        su += j-i
if su % 3 == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin
n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))
b = list(map(int,stdin.readline().rstrip().split()))
if sum(a)*3 == sum(b)*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()))
if sum(a)>sum(b):
  print("No")
else:
  ca = 0
  cb = 0
  for i in range(n):
    if a[i]>b[i]:
      cb += a[i]-b[i]
    else:
      ca += (b[i]-a[i]+1)//2
      cb += (b[i]-a[i])%2
  x = sum(b)-sum(a)
  if x > ca and x > cb and (x-ca)*2 == x-cb:
    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()))
if sum(a)>sum(b):
  print("No")
else:
  ca = 0
  cb = 0
  for i in range(n):
    if a[i]>b[i]:
      cb += a[i]-b[i]
    else:
      ca += (b[i]-a[i]+1)//2
      cb += (b[i]-a[i])%2
  if (sum(b)-sum(a)-ca)*2 == sum(b)-sum(a)-cb:
    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()))
if sum(a)>sum(b):
  print("No")
else:
  ca = 0
  cb = 0
  for i in range(n):
    if a[i]>b[i]:
      cb += a[i]-b[i]
    else:
      ca += (b[i]-a[i]+1)//2
      cb += (b[i]-a[i])%2
  if ca == cb:
    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()))
if sum(a)>sum(b):
  print("No")
else:
  cnt = 0
  for i in range(n):
    if a[i]>b[i]:
      cnt += a[i]-b[i]
  if cnt>=(sum(b)-sum(a)):
    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()))
if sum(a)>sum(b):
  print("No")
else:
  cnt = 0
  for i in range(n):
    if a[i]>b[i]:
      cnt += a[i]-b[i]
  if cnt>(sum(b)-sum(a)):
    print("No")
  else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
B = np.array(list(map(int, input().split())))
A_tot = np.sum(A)
B_tot = np.sum(B)
cupture = np.sum((A-B) * ((A-B) > 0))
if A_tot + 2 * cupture < B_tot + cupture:
	print('Yes')
elif A_tot + 2 * cupture > B_tot + cupture:
	print('No')
else:
	C = (B-A)[(B-A)>2] % 2
	cnt_C = np.count_nonzero(C)
	if cnt_C > 0:
		print('No')
	else:
		print('Yes')

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
B = np.array(list(map(int, input().split())))
A_tot = np.sum(A)
B_tot = np.sum(B)
cupture = np.sum((A-B) * ((A-B) > 0))
if A_tot + 2 * cupture <= B_tot + cupture:
	print('Yes')
else:
	print('No')

Submission status: Wrong Answer

Solution code:
import sys

use_clipboard=True
bbn=1000000007
	
#+++++

		
def main():
	n = int(input())
	bl = list(map(int, input().split()))
	cl = list(map(int, input().split()))
	
	dd = sum([max(c-b,0) for b,c in zip(bl,cl)])
	pp = sum([max(b-c,0) for b,c in zip(bl, cl)])
	if pp*2 > dd:
		return 'No'
	return 'Yes'
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
class input_clipboard:
	def __init__(self,s):
		self.input_l=s.splitlines()
		self.ii=0
		
	def input(self):
		ret = self.input_l[self.ii]
		self.ii+=1
		return ret

if __name__ == "__main__":
	if sys.platform =='ios':
		if use_clipboard:
			import clipboard
			input_text=clipboard.get()
			ic=input_clipboard(input_text)
			input = lambda : ic.input()
		else:
			sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

ans = "Yes"

for i in range(n):
    if (b[i] - a[i]) < 0:
        ans = "No"
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
N=input()
A=map(int, sys.stdin.readline().split())
B=map(int, sys.stdin.readline().split())
A.sort()
B.sort()

for a,b in zip(A,B):
    if a>b:
        print "No"
        quit()
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_sum = sum(A)
B_sum = sum(B)

if A_sum > B_sum:
  print("No")
  quit()
  
x = B_sum - A_sum
count = 0
count2 = 0
for i in range(N):
  if A[i] > B[i]:
    count += A[i] - B[i]
  else:
    count2 += B[i] - A[i]
    
if count > x:
  print("No")
  quit()
  
if count2 > 2 * x:
  print("No")
  quit()
  
print("Yes")

Submission status: Wrong Answer

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

A_sum = sum(A)
B_sum = sum(B)

if A_sum > B_sum:
  print("No")
  quit()
  
x = B_sum - A_sum
count = 0
for i in range(N):
  if A[i] > B[i]:
    count += A[i] - B[i]
    
if count > x:
  print("No")
  quit()
  
print("Yes")

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()
tmp = sum(b) - sum(a)
if tmp < 0:
    print('No')
    exit()

total = 0
for i in range(N):
    if a[i] <= b[i]:
        total += b[i] - a[i]
if tmp == total:
    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_short = 0
a_odd = 0
b_short = 0
for i in range(N):
    a_short += max(0, B[i] - A[i])
    if B[i] - A[i] > 0 and (B[i] - A[i]) % 2 == 1:
        a_odd += 1
    b_short += max(0, A[i] - B[i])

if b_short * 2 <= (a_short // 2) + ((a_odd + 1) // 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()))

a_short = 0
a_odd = 0
b_short = 0
for i in range(N):
    a_short += max(0, B[i] - A[i])
    if (B[i] - A[i]) % 2 == 1:
        a_odd += 1
    b_short += max(0, A[i] - B[i])

if b_short * 2 <= a_short + (a_odd + 1) // 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()))

a_short = 0
b_short = 0
for i in range(N):
    a_short += max(0, B[i] - A[i])
    b_short += max(0, A[i] - B[i])

if b_short * 2 <= a_short:
    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()
ans = 'Yes'
for i in range(n):
    if a[i] > b[i]:
        ans = 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
# print(N, A, B)
d1 = 0
d2 = 0
for i in range(N):
    a = A[i]
    b = B[i]
    if a > b:
        d1 += a - b
    elif a < b:
        d2 += b - a
# print(d1, d2)
if d1 * 2 > d2:
    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()))

sabun=[A[i]-B[i] for i in range(N)]

print("Yes" if (sum([i for i in sabun if i>0])*2+sum([i for i in sabun if i<0]))<=0 else "No")

Submission status: Wrong Answer

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

sabun=[B[i]-A[i] for i in range(N)]

print("Yes" if (sum([i for i in sabun if i>0])+sum([i for i in sabun if i<0])*2)>=0 else "No")

Submission status: Wrong Answer

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

sabun=[B[i]-A[i] for i in range(N)]

print("Yes" if (sum([i for i in sabun if i>0])+sum([i for i in sabun if i<0])*2)>0 else "No")

Submission status: Wrong Answer

Solution code:
import sys


N, *AB = map(int, open(0).read().split())
A = AB[:N]
B = AB[N:]

# 手前から数を揃えて余りを蓄積させていく
# 最後に余りをやりくりできれば Yes さもなくば No 
res_a = 0
res_b = 0
for i, (a, b) in enumerate(zip(A, B)):
  if i < N - 1:
    if a == b:
      continue
    
    # b の方が大きい場合、偶奇を合わせて res_b を増やす
    elif a < b:
      # 偶奇を合わせる
      if (b - a) % 2:
        b += 1
        if res_b:
          res_b -= 1
        else:
          a += 2
          
      # res_a が余っていれば補填する
      if b - a <= res_a:
        res_a -= b - a
      # res_a で補填できなければ res_b を増やす
      else:
        a += res_a
        res_a = 0
        res_b += (b - a) // 2
      
    else:
      # bの方が小さい場合、余っている数で補填する
      # 補填できれば、continue
      if a - b <= res_b:
        res_b -= a - b
      # 補填できなければ、偶奇を合わせて res_a を増やす
      else:
        b += res_b
        res_b = 0
        
        if (a - b) % 2:
          if res_a:
            res_a -= 2
          
          a += 2
          b += 1
        
        res_a += 2 * (a - b)
        
  
  else:
    a += res_a
    b += res_b
      
    if a > b:
      print("No")
      sys.exit()
    else:
      print("Yes")
      sys.exit()

Submission status: Wrong Answer

Solution code:
import sys


N, *AB = map(int, open(0).read().split())
A = AB[:N]
B = AB[N:]

# 手前から数を揃えて余りを蓄積させていく
# 最後に余りをやりくりできれば Yes さもなくば No 
res_a = 0
res_b = 0
for i, (a, b) in enumerate(zip(A, B)):
  if i < N - 1:
    if a == b:
      continue
    
    # b の方が大きい場合、偶奇を合わせて res_b を増やす
    elif a < b:
      # 偶奇を合わせる
      if (b - a) % 2:
        b += 1
        if res_b:
          res_b -= 1
        else:
          a += 2
          
      # res_a が余っていれば補填する
      if b - a <= res_a:
        res_a -= b - a
      # res_a で補填できなければ res_b を増やす
      else:
        a += res_a
        res_a = 0
      res_b += (b - a) // 2
      
    else:
      # bの方が小さい場合、余っている数で補填する
      # 補填できれば、continue
      if a - b <= res_b:
        res_b -= a - b
      # 補填できなければ、偶奇を合わせて res_a を増やす
      else:
        b += res_b
        res_b = 0
        
        if (a - b) % 2:
          if res_a:
            res_a -= 2
          
          a += 2
          b += 1
        
        res_a += 2 * (a - b)
        
  
  else:
    a += res_a
    b += res_b
      
    if a > b:
      print("No")
      sys.exit()
    else:
      print("Yes")
      sys.exit()

Submission status: Wrong Answer

Solution code:
import sys


N, *AB = map(int, open(0).read().split())
A = AB[:N]
B = AB[N:]

# 手前から数を揃えて余りを蓄積させていく
# 最後に余りをやりくりできれば Yes さもなくば No 
res_a = 0
res_b = 0
for i, (a, b) in enumerate(zip(A, B)):
  if i < N - 1:
    if a == b:
      continue
    elif a < b:
      # 偶奇を合わせる
      if (b - a) % 2:
        b += 1
        if res_b:
          res_b -= 1
        else:
          a += 2
          
      if b - a <= res_a:
        res_a -= b - a
      else:
        a += res_a
        res_a = 0
      res_b += (b - a) // 2
      
    else:
      if a - b <= res_b:
        res_b -= a - b
      else:
        res_a += 2 * (a - b - res_b)
        res_b = 0
  
  else:
    a += res_a
    b += res_b
      
    if a > b:
      print("No")
      sys.exit()
    else:
      print("Yes")
      sys.exit()

Submission status: Wrong Answer

Solution code:
import sys


N, *AB = map(int, open(0).read().split())
A = AB[:N]
B = AB[N:]

# 手前から数を揃えて余りを蓄積させていく
# 最後に余りをやりくりできれば Yes さもなくば No 
res_a = 0
res_b = 0
for i, (a, b) in enumerate(zip(A, B)):
  if i < N - 1:
    if a == b:
      continue
    elif a < b:
      # 偶奇を合わせる
      if (b - a) % 2:
        if res_b:
          res_b -= 1
        b += 1
    
      res_b += (b - a) // 2
      
    else:
      if a - b <= res_b:
        res_b -= a - b
      else:
        res_a += 2 * (a - b - res_b)
        res_b = 0
  
  else:
    a += res_a
    b += res_b
      
    if a > b:
      print("No")
      sys.exit()
    else:
      print("Yes")
      sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial, ceil, floor
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, M, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

N, = map(int, input().split())
A = [int(v) for v in input().split()]
B = [int(v) for v in input().split()]
m = []

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

if sum(B) - sum(A) >= ca + cb:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial, ceil, floor
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, M, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

N, = map(int, input().split())
A = [int(v) for v in input().split()]
B = [int(v) for v in input().split()]
m = []

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

if sum(B) - sum(A) == ca + cb:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial, ceil
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, M, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

N, = map(int, input().split())
A = [int(v) for v in input().split()]
B = [int(v) for v in input().split()]
m = []

for i in range(N):
    a, b = A[i], B[i]
    m.append(a - b)

if sum(m) > 0:
    print("No")
    exit()

for i in range(N):
    if m[i] < 0 and m[i] % 2 != 0:
        m[i] += 1

if sum(m) > 0:
    print("No")
    exit()

f = True
for i in range(N):
    if A[i] > B[i]:
        f = False
        break
if f:
    print("Yes")
    exit()

m.sort()
for i in range(N):
    if m[i] < 0:
        t = (m[i] * -1) // 2
        p = bisect.bisect_left(m, t)
        if p < N and m[p] == t:
            m[i] = 0
            m[p] = 0
        else:
            p2 = bisect.bisect_left(m, t - 1)
            if p2 < N and m[p2] == t - 1:
                m[i] = 0
                m[p2] = 0
            else:
                print("No")
                exit()
for v in m:
    if v != 0:
        print("No")
        exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial, ceil
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, M, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

N, = map(int, input().split())
A = [int(v) for v in input().split()]
B = [int(v) for v in input().split()]
m = []

for i in range(N):
    a, b = A[i], B[i]
    m.append(a - b)

if sum(m) > 0:
    print("No")
    exit()

for i in range(N):
    if m[i] < 0 and m[i] % 2 != 0:
        m[i] += 1

if sum(m) > 0:
    print("No")
    exit()

m.sort()
for i in range(N):
    if m[i] < 0:
        t = (m[i] * -1) // 2
        p = bisect.bisect_left(m, t)
        if p < N and m[p] == t:
            m[i] = 0
            m[p] = 0
        else:
            p2 = bisect.bisect_left(m, t - 1)
            if p2 < N and m[p2] == t - 1:
                m[i] = 0
                m[p2] = 0
            else:
                print("No")
                exit()
for v in m:
    if v != 0:
        print("No")
        exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
d1 = 0
d2 = 0
for i in range(N):
    if A[i]>B[i]:
        d1 += (A[i]-B[i])
    else:
        d2 += (B[i]-A[i])
if d2>=2*d1:
    flag = 0
else:
    flag = 1
if flag==0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

s = 0
stop = 0
for i in range(n-1, -1, -1):
    if stop:
        break
    if a[i] < b[i]:
        if (a[i] + b[i]) % 2 == 1:
            a[i] += 2
            b[i] += 1
        p = (b[i] - a[i]) // 2
        a[i] = b[i]

        for j in range(s, n):
            if p > 0 and a[j] > b[j]:
                q = min(p, a[j] - b[j])
                p -= q
                b[j] += q
            if a[j] == b[j]:
                s = j
            if p == 0:
                break
            if p != 0:
                stop = 1

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
dif_pos, dif_neg = 0, 0
for a, b in zip(A,B):
  if a<b:dif_neg +=b-a
  elif b<a:dif_pos +=a-b
print('Yes' if dif_neg>=dif_pos*2 else 'No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
dif_pos, dif_neg = 0, 0
for a, b in zip(A,B):
  if a<b:dif_neg +=b-a
  elif b<a:dif_pos +=a-b
print('Yes' if dif_neg//2>dif_pos else '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()
flag = True
for a, b in zip(A, B):
    if a > b:
        flag = False
if flag: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=b=0
for i in range(N):
    if A[i]>B[i]:
        a+=A[i]-B[i]
    else:
        b+=B[i]-A[i]
if a*2+b<=2*(sum(B)-sum(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()))

a=b=0
for i in range(N):
    if A[i]>B[i]:
        a+=A[i]-B[i]
    else:
        b+=B[i]-A[i]
if a*2>b:
    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
for i in range(N):
    if A[i]>B[i]:
        a+=A[i]-B[i]
    else:
        b+=B[i]-A[i]
if a*2>b:
    print('No')
else:
    print('yes')

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
b_ls = [int(i) for i in sys.stdin.readline().split()]
# 全部正ならok
# 負に1足して正から2を引く
diff_ls = [b - a for a, b in zip(a_ls, b_ls)]
diff_ls = [i if i <= 0 else i // 2 for i in diff_ls]
if sum(diff_ls) > 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

x = sum(B) - sum(A)
if x >= 0 and sum([max(a-b, 0) for a, b in zip(A, B)]) <= x:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np


def main():
    N = int(input())
    A = np.array(list(map(int, input().split())))
    B = np.array(list(map(int, input().split())))
    sum_A = np.sum(A)
    sum_B = np.sum(B)
    diff_AB = A - B

    if sum_A > sum_B:
        ans = 'No'
    else:
        cnt_1 = 0
        cnt_2 = 0
        for d in diff_AB:
            if d > 0:
                cnt_1 += d
            else:
                cnt_2 -= (d + 1) // 2

        if max(cnt_1, cnt_2) <= sum_B - sum_A:
            ans = 'Yes'
        else:
            ans = 'No'

    print(ans)


main()

Submission status: Wrong Answer

Solution code:
import numpy as np


def main():
    N = int(input())
    A = np.array(list(map(int, input().split())))
    B = np.array(list(map(int, input().split())))
    sum_A = np.sum(A)
    sum_B = np.sum(B)
    diff_AB = A - B

    if sum_A >= sum_B:
        ans = 'No'
    else:
        cnt_1 = 0
        cnt_2 = 0
        for d in diff_AB:
            if d > 0:
                cnt_1 += d
            else:
                cnt_2 -= (d + 1) // 2

        if max(cnt_1, cnt_2) <= sum_B - sum_A:
            ans = 'Yes'
        else:
            ans = 'No'

    print(ans)


main()

Submission status: Wrong Answer

Solution code:
import numpy as np


def main():
    N = int(input())
    A = np.array(list(map(int, input().split())))
    B = np.array(list(map(int, input().split())))
    sum_A = np.sum(A)
    sum_B = np.sum(B)
    diff_AB = A - B

    if np.all(A == B):
        ans = 'Yes'
    elif sum_A >= sum_B:
        ans = 'No'
    else:
        cnt_1 = 0
        cnt_2 = 0
        for d in diff_AB:
            if d > 0:
                cnt_1 += d
            else:
                cnt_2 -= (d + 1) // 2

        if max(cnt_1, cnt_2) <= sum_B - sum_A:
            ans = 'Yes'
        else:
            ans = 'No'

    print(ans)


main()

Submission status: Wrong Answer

Solution code:
import numpy as np


def main():
    N = int(input())
    A = np.array(list(map(int, input().split())))
    B = np.array(list(map(int, input().split())))
    sum_A = np.sum(A)
    sum_B = np.sum(B)
    diff_AB = A - B

    cnt = 0
    for d in diff_AB:
        if d > 0:
            cnt += d
        else:
            cnt += (-d - 1) // 2

    if cnt <= sum_B - sum_A:
        ans = 'Yes'
    else:
        ans = 'No'

    print(ans)


main()

Submission status: Wrong Answer

Solution code:
import numpy as np


def main():
    N = int(input())
    A = np.array(list(map(int, input().split())))
    B = np.array(list(map(int, input().split())))
    sum_A = np.sum(A)
    sum_B = np.sum(B)
    diff_AB = A - B

    if np.all(A == B):
        ans = 'Yes'
    elif sum_A >= sum_B:
        ans = 'No'
    else:
        cnt = 0
        for d in diff_AB:
            if d > 0:
                cnt += d
            else:
                cnt += (-d - 1) // 2

        if cnt <= sum_B - sum_A:
            ans = 'Yes'
        else:
            ans = 'No'

    print(ans)


main()

Submission status: Wrong Answer

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

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

d=[0]*N
p=0
m=0
for i in range(N):
    d[i]=a[i]-b[i]
    if(d[i]>0):
        p+=d[i]
    else:
        m+=d[i]

if(abs(m)>=abs(p)*2):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    B = [int(x) for x in input().split()]
    a,b = 0,0

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
d = 0
cur = 0
flag=0
for i in range(N):
    if A[i]>B[cur]:
        while B[cur]<A[i]:
            cur += 1
            if cur==N:
                flag = 1
                break
        if flag==1:break
    if A[i]==B[cur]:
        d += 1
        cur += 1
a = sum(A)
b = sum(B)
if N-d<=b-a:
    print("Yes")
else:
    print("No")