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 sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
a = LIST()
b = LIST()
dif = sum(b) - sum(a)
if dif < 0:
    print('No')
    exit()
cnt = 0
for i in range(n):
    tmp = b[i] - a[i]
    if tmp > 0:
        cnt += tmp // 2
    else:
        cnt += -tmp
if dif < cnt:
    print('No')
    exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
B = [int(x) for x in stdin.readline().rstrip().split()]
A.sort()
B.sort()
f = True
for i in range(N):
    if  A[i] - B[i] > 0:
        f = False
if f:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
B = [int(x) for x in stdin.readline().rstrip().split()]
C = []
for i in range(N):
    C.append(B[i]-A[i])

c_1 = sum([i for i in C if i > 0])
c_2 = sum([i for i in C if i < 0])

if c_1 >= c_2*-2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

m = sum(B) - sum(A)
if m <= -1:
    print("No")
else:
    # print("m",m)
    M = [m, m]
    for i in range(n):
        di = B[i] - A[i]
        if di > 0:
            if di % 2 == 1:
                di -= 1
                M[1] -= 1
            M[0] -= di//2
        else:
            M[1] -= -di
    # print(M)
    if M[0] >= 0 and M[1] >= 0 and M[0]*2 == M[1]:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

if sum(a) > sum(b):
    print("No")
    exit()
    
for i in range(n):
    if a[i] > b[i]:
        print("No")
        exit()

print("Yes")

Submission status: Wrong Answer

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

if sum(a) < sum(b):
    print("No")
    exit()
    
for i in range(n):
    if a[i] > b[i]:
        print("No")
        exit()

print("Yes")

Submission status: Wrong Answer

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

for i in range(n):
    if a[i] > b[i]:
        print("No")
        exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))

m = sum(B) - sum(A)
if m < 0:
    print('No')
    exit()

import math
num_add = 0
for i in range(N):
    if B[i] > A[i]:
        n = int(math.ceil((B[i] - A[i])/2))
        num_add += n
        B[i] += n * 2

rest = (m - num_add) * 2
if rest < 0:
    print('No')
    exit()

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

# print(num_add, rest)
if num_add + rest != m:
    print('No')
    exit()

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()))
    a.sort()
    b.sort()
    
    flag=True
    for i in range(n):
        if a[i]-b[i] <= 0:
            continue
        else:
            flag=False
            break
    
    if flag:
        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()))
ans = 0
for a, b in zip(A, B):
  if a > b:
    ans += a - b
  elif a < b:
    ans += -((a-b)//2)
print("Yes" if sum(B) - sum(A) >= ans else "No")

Submission status: Wrong Answer

Solution code:
import heapq as hq
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
n = sum(B) - sum(A)
hq.heapify(A)
hq.heapify(B)
for i in range(n):
  a = hq.heappop(A)
  hq.heappush(A, a+2)
  b = hq.heappop(B)
  hq.heappush(B, b+1)
for i in range(N):
  if hq.heappop(A) != hq.heappop(B):
    print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
# B - Two Arrays
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
sum_a=sum(a)
sum_b=sum(b)
a_cnt,b_cnt=0,0

for aa,bb in zip(a,b):
    if aa>bb:
        a_cnt+=aa-bb
    elif aa<bb:
        b_cnt+=((bb-aa)//2)*2

print('Yes') if a_cnt<=b_cnt 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_a=sum(a)
sum_b=sum(b)
if sum_a>sum_b:
    print('No')
    exit()
lo=0
hi=10**9
mid=0
while hi-lo>1:
    mid=(hi+lo)//2
    if sum_a+2*mid<=sum_b+mid:
        lo=mid
    else:
        hi=mid
# print(lo)
posi=0
neg=0
for aa,bb in zip(a,b):
    if bb-aa>=0:
        posi+=bb-aa
    else:
        neg+=abs(bb-aa)
if sum_a+2*lo==sum_b+lo:
    if neg<=lo and posi/2<=lo:
        print('Yes')
    else:
        print('No')
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_a=sum(a)
sum_b=sum(b)
if sum_a>sum_b:
    print('No')
    exit()
lo=0
hi=10**9
mid=0
while hi-lo>1:
    mid=(hi+lo)//2
    if sum_a+2*mid<=sum_b+mid:
        lo=mid
    else:
        hi=mid
# print(lo)
posi=0
for aa,bb in zip(a,b):
    if bb-aa>0:
        posi+=bb-aa
if sum_a+2*lo==sum_b+lo:
    if posi/2>lo:
        print('No')
    else:
        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()]

A.sort(); B.sort()

flag = True
for a,b in zip(A,B):
    if a <= b:
        continue
    else:
        flag = False

if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin
from math import ceil
def main():
	readline=stdin.readline
	N=int(readline())
	a=list(map(int,readline().split()))
	b=list(map(int,readline().split()))

	count=0
	for i in range(N):  #一旦、任意のiについてa_iをb_iよりも大きくする。
		if a[i]<b[i]:   #その時の回数をcountとする。
			c=ceil((b[i]-a[i])/2)
			count+=c
			a[i]+=2*c

	for i in range(N):  #count以内の回数でbも大きくしていく。
		if b[i]<a[i]:   #上の手順後にa<=bならa_i<b_iのiについて
			d=b[i]-a[i] #a_iとb_iを同時に増やしていけばa=bにすることができ、
			b[i]+=d     #a>bなら逆転不可能でa=bにすることはできない。
			count-=d

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

if __name__=="__main__":
	main()

Submission status: Wrong Answer

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    B = [int(b) for b in input().split()]
    C = []
    for i in range(N): C.append(A[i] - B[i])
    #print(C)
    sumA = sum(A)
    sumB = sum(B)
    if sumA > sumB: print("No")
    else:
        count = 0
        for i, c in enumerate(C):
            if c > 0: count += c
            else: count += (-1 * c + 1) // 2
        if count > sumB - sumA: print("No")
        else: print("Yes")

    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    B = [int(b) for b in input().split()]
    C = []
    for i in range(N): C.append(A[i] - B[i])
    #print(C)
    sumA = sum(A)
    sumB = sum(B)
    if sumA >= sumB: print("No")
    else:
        count = 0
        for i, c in enumerate(C):
            if c > 0: count += c
            else: count += (-1 * c + 1) // 2
        if count > sumB - sumA: print("No")
        else: print("Yes")

    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    B = [int(b) for b in input().split()]
    A.sort()
    B.sort()
    C = []
    for i in range(N): C.append(A[i] - B[i])
    #print(C)
    sumA = sum(A)
    sumB = sum(B)
    if sumA >= sumB: print("No")
    else:
        for i, c in enumerate(C):
            if c > 0: 
                print("No")
                break
        else:
            print("Yes")

    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    B = [int(b) for b in input().split()]
    A.sort()
    B.sort()
    C = []
    for i in range(N): C.append(A[i] - B[i])
    print(C)
    sumA = sum(A)
    sumB = sum(B)
    if sumA >= sumB: print("No")
    else:
        for i, c in enumerate(C):
            if c > 0: 
                print("No")
                break
        else:
            print("Yes")

    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
from sys import stdin
from math import ceil
def main():
	readline=stdin.readline
	N=int(readline())
	a=list(map(int,readline().split()))
	b=list(map(int,readline().split()))
	a.sort()
	b.sort()
	a_count=0
	s=sum(b)-sum(a)

	for i in range(N):
		if a[i]<b[i]:
			a_count+=ceil((b[i]-a[i])/2)

	if a_count<=s:
		print("Yes")
	else:
		print("No")

if __name__=="__main__":
	main()

Submission status: Wrong Answer

Solution code:
from sys import stdin
from math import ceil
def main():
	readline=stdin.readline
	N=int(readline())
	a=list(map(int,readline().split()))
	b=list(map(int,readline().split()))
	a.sort()
	b.sort()
	a_count=0

	for i in range(N):
		if a[i]<b[i]:
			c=ceil((b[i]-a[i])/2)
			a_count+=c

	if sum(b)-sum(a)<0 or 3<sum(b)-sum(a):
		print("No")
	elif a_count<=sum(b)-sum(a):
		print("Yes")
	else:
		print("No")

if __name__=="__main__":
	main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [int(i) for i in input().split()]
    A.sort()
    B.sort()
    D = [b-a for a, b in zip(A, B)]
    D_p = sum(d for d in D if d > 0)
    D_n = sum(-d for d in D if d < 0)
    print("Yes" if D_p >= 2*D_n else "No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [int(i) for i in input().split()]
    D = [b-a for a, b in zip(A, B)]
    D_p = sum(d for d in D if d > 0)
    D_n = sum(-d for d in D if d < 0)
    print("Yes" if D_p >= 2*D_n else "No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin
from math import ceil
def main():
	readline=stdin.readline
	N=int(readline())
	a=list(map(int,readline().split()))
	b=list(map(int,readline().split()))
	a.sort()
	b.sort()
	a_count=0
	b_count=0

	for i in range(N):
		if a[i]<b[i]:
			a_count+=ceil((b[i]-a[i])/2)
			a[i]+=2*ceil((b[i]-a[i])/2)
		if b[i]<a[i]:
			b_count+=a[i]-b[i]
			b[i]+=a[i]-b[i]
	
	if sum(b)-sum(a)<0 or 3<sum(b)-sum(a):
		print("No")
	elif a_count<=3 and b_count<=3:
		print("Yes")
	else:
		print("No")

if __name__=="__main__":
	main()

Submission status: Wrong Answer

Solution code:
from sys import stdin
from math import ceil
def main():
	readline=stdin.readline
	N=int(readline())
	a=list(map(int,readline().split()))
	b=list(map(int,readline().split()))
	a.sort()
	b.sort()
	a_count=0
	b_count=0

	for i in range(N):
		if a[i]<b[i]:
			a_count+=ceil((b[i]-a[i])/2)
			a[i]+=2*ceil((b[i]-a[i])/2)
		if b[i]<a[i]:
			b_count+=a[i]-b[i]
			b[i]+=a[i]-b[i]
	
	if a_count<=3 and b_count<=3:
		print("Yes")
	else:
		print("No")

if __name__=="__main__":
	main()

Submission status: Wrong Answer

Solution code:
from sys import stdin
from math import ceil
def main():
	readline=stdin.readline
	N=int(readline())
	a=list(map(int,readline().split()))
	b=list(map(int,readline().split()))
	a.sort()
	b.sort()
	a_count=0
	b_count=0

	for i in range(N):
		if a[i]<b[i]:
			a_count+=ceil((b[i]-a[i])/2)
			a[i]+=ceil((b[i]-a[i])/2)
		if b[i]<a[i]:
			b_count+=a[i]-b[i]
			b[i]+=a[i]-b[i]
	
	if a_count<=3 and b_count<=3:
		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()))

a_sum, b_sum = sum(A), sum(B)
turns = b_sum - a_sum
a_small = 0
b_small = 0
for a, b in zip(A,B):
    if a < b:
        a_small += (b - a + 1) // 2
    else:
        b_small += a - b
if a_small <= turns and b_small * 2 <= turns:
    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)
p = 0
q = 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
    else:
        pass
#print(k, p, q)
if p <= k and q <= 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_small = 0
b_small = 0
for a, b in zip(A,B):
    if a < b:
        a_small += b - a
    else:
        b_small += a - b
if a_small < b_small * 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()))

a_sum, b_sum = sum(A), sum(B)
turns = b_sum - a_sum
a_small = 0
b_small = 0
for a, b in zip(A,B):
    if a < b:
        a_small += b - a
    else:
        b_small += a - b
ans = True
if turns < 0: ans = False
if b_small > turns: ans = False
a_small -= 2 * b_small
turns -= b_small
if a_small > turns * 2: ans = False
if ans:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [int(i) for i in input().split()]
    A.sort()
    B.sort()
    D = [b-a for a, b in zip(A, B)]
    # print(A, B, sep="\n")
    print("Yes" if all(d >= 0for d in D) else "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()))

a_sum, b_sum = sum(A), sum(B)
turns = b_sum - a_sum
a_small = 0
b_small = 0
for a, b in zip(A,B):
    if a < b:
        a_small += b - a
    else:
        b_small += a - b
ans = True
if b_small > turns: ans = False
a_small -= 2 * b_small
if a_small > (turns - b_small) * 2: ans = False
if ans:
    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_sum, b_sum = sum(A), sum(B)
turns = b_sum - a_sum
a_small = 0
b_small = 0
for a, b in zip(A,B):
    if a < b:
        a_small += b - a
    else:
        b_small += a - b
if b_small <= turns:
    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()))
t = sum(b)-sum(a)
res=0
for i in range(n):
    res += (b[i]-a[i]+1)//2
if res > t:
  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()))
t = sum(b)-sum(a)
res=0
for i in range(n):
  if a[i]>=b[i]:
    res += a[i]-b[i]
  else:
    res += (b[i]-a[i]+1)//2
if res > t:
  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()))

aaa = 0
bbb = 0

for a, b in zip(A, B):
    if a > b:
        aaa += a - b
    else:
        bbb += b - a

ans = "Yes"
if aaa > bbb:
    ans = "No"
if bbb % 2 == 1:
    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()))
a.sort()
b.sort()
for i in range(n):
    if b[i] < a[i]:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sum(list(map(int,input().split())))
b = sum(list(map(int,input().split())))
if (a - b) % 2 == 0 and a != 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=0
b=0
for i in range(N):
  if A[i]>B[i]:
    a+=A[i]-B[i]
  else:
    b+=(B[i]-A[i])//2
if a<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=sorted(A)
B=sorted(B)
x=sum(B)-sum(A)
cnt=0
for i in range(N):
  if B[i]<A[i]:
    cnt+=(A[i]-B[i])
  else:
    cnt+=(B[i]-A[i]+1)//2
if x<cnt:
  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=sorted(A)
B=sorted(B)
x=sum(B)-sum(A)
cnt=0
for i in range(N):
  if B[i]<A[i]:
    cnt+=(A[i]-B[i])
  else:
    cnt+=(B[i]-A[i])/2
if x<cnt:
  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=sorted(A)
B=sorted(B)
x=sum(B)-sum(A)
cnt=0
for i in range(N):
  if B[i]>A[i]:
    cnt+=(B[i]-A[i])//2
  else:
    cnt+=(A[i]-B[i])
if x<cnt:
  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=sorted(A)
B=sorted(B)
x=sum(B)-sum(A)
cnt=0
for i in range(N):
  if B[i]>A[i]:
    cnt+=(B[i]-A[i])/2
  else:
    cnt+=(A[i]-B[i])
if x<cnt:
  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=sorted(A)
B=sorted(B)
x=sum(B)-sum(A)
cnt=0
for i in range(N):
  a=B[i]-A[i]
  if a>0:
    cnt+=(a+1)//2
  else:
    cnt+=(-a)
if x<cnt:
  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=sorted(A)
B=sorted(B)
x=sum(B)-sum(A)
cnt=0
for i in range(N):
  if B[i]-A[i]>0:
    cnt+=B[i]-A[i]
if x<cnt:
  print('No')
else:
  print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
cnt = 0
for i in a:
    if i % 2 == 0:
        cnt += 1
b = list(map(int,input().split()))
ccnt = 0
for i in b:
    if i % 2 != 0:
        ccnt += 1

if cnt == ccnt:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import math

n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
total = sum(B) - sum(A)
cnt1, cnt2 = 0,0

for i in range(n):
    if A[i] > B[i]:
        cnt1 += A[i] - B[i]
    elif A[i] < B[i]:
        cnt2 += math.floor((B[i]-A[i])/2)

if max(cnt1, cnt2) <= total:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import math

n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
total = sum(B) - sum(A)
cnt1, cnt2 = 0,0

for i in range(n):
    if A[i] > B[i]:
        cnt1 += A[i] - B[i]
    elif A[i] < B[i]:
        cnt2 += math.floor((B[i]-A[i])/2)

print(total ,cnt1 ,cnt2)
if max(cnt1, cnt2) <= total:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import math

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

total = sum(A) - sum(B)
cnt1, cnt2 = 0,0
for i in range(n):
    if A[i] > B[i]:
        cnt1 += A[i] - B[i]
    elif A[i] < B[i]:
        cnt2 += math.floor((B[i]-A[i])/2)
if max(cnt1, cnt2) <= total:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import math

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

total = sum(A) - sum(B)
cnt1, cnt2 = 0,0
for i in range(n):
    if A[i] > B[i]:
        cnt1 = A[i] - B[i]
    elif A[i] < B[i]:
        cnt2 = math.floor((B[i]-A[i])/2)
if max(cnt1, cnt2) <= total:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import math

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

total = sum(A) - sum(B)
cnt1, cnt2 = 0,0
for i in range(n):
    if A[i] < B[i]:
        cnt1 += math.ceil(A[i] - B[i] / 2)
    else:
        cnt2 += (A[i] - B[i])
if max(cnt1, cnt2) <= 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()))
cnt = 0
for i in range(n):
    if A[i] > B[i]:
        cnt -= (A[i] - B[i])
    else:
        cnt += (B[i] - A[i])//2
print('Yes' if cnt > 0 else '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)
cnt1 = 0
cnt2 = 0
for i in range(n):
    if A[i] > B[i]:
        cnt1 += (A[i] - B[i])
    else:
        cnt2 += (B[i] - A[i])//2

if min(cnt1, cnt2) <= 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()))

x = sum(B) - sum(A)
cnt1 = 0
cnt2 = 0
for i in range(n):
    if A[i] > B[i]:
        cnt1 += (A[i] - B[i])
    else:
        cnt2 += (B[i] - A[i])//2

if max(cnt1, cnt2) <= 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()))

import math

count = 0
for a, b in zip(A, B):
    if a - b >= 0:
        continue
    else:
        count += math.ceil((b - a) / 2)

diff = sum(A) - sum(B)

# print(diff, count)
if diff < 0 and diff % 2 == 1 and abs(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()))
diff = sum(A) - sum(B)
if diff < 0 and diff % 2 == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def ceil(a, b):
    return (a + b - 1) // b


N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
n = sum(b) - sum(a)
cnt = 0
for _a, _b in zip(a, b):
    if _a > _b:
        cnt += _a - _b
    if _a < _b:
        cnt += ceil(_b - _a, 2)
if cnt <= n:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
def ceil(a, b):
    return (a + b - 1) // b


N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
n = sum(b) - sum(a)
for _a, _b in zip(a, b):
    if _a > _b:
        n -= _a - _b
    if _a < _b:
        n -= ceil(_b - _a, 2)
        n -= (_a + _b) & 1
if n >= 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
def ceil(a, b):
    return (a + b - 1) // b


N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
n = sum(b) - sum(a)
for _a, _b in zip(a, b):
    if _a > _b:
        n -= _a - _b
    if _a + _b & 1:
        n -= 1
if n >= 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
def ceil(a, b):
    return (a + b - 1) // b


N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
n = sum(b) - sum(a)
for _a, _b in zip(a, b):
    if _a > _b:
        n -= _a - _b
    if _a < _b:
        n -= ceil(_b - _a, 2)
if n >= 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()))
n = sum(b) - sum(a)
for _a, _b in zip(a, b):
    if _a > _b:
        n -= _a - _b
    if _a < _b:
        n -= (_b - _a) // 2
if n >= 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=0
for i in range(n):
    if a[i]<b[i]:
        p=(b[i]-a[i]+1)//2
        a[i]+=p*2
        while p>0 and k<n:
            if a[k]<b[k] and (a[k]-b[k])%2==1:
                b[k]+=1
                p-=1
            if a[k]-b[k]>p:
                b[k]+=p
                p=0
            elif a[k]-b[k]>0:
                p-=a[k]-b[k]
                b[k]=a[k]
            k+=1
            # print(a,b,k,p,i)
        b[-1]+=p
# print(a,b)
if a[:-1]==b[:-1] and a[-1]<=b[-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()))
k=0
for i in range(n):
    if a[i]<b[i]:
        p=(b[i]-a[i]+1)//2
        a[i]+=p*2
        while p>0 and k<n:
            if a[k]-b[k]>p:
                b[k]+=p
                p=0
            elif a[k]-b[k]>0:
                b[k]=a[k]
                p-=a[k]-b[k]
            k+=1
            # print(a,b,k,p,i)
        b[-1]+=p
# print(a,b)
if a[:-1]==b[:-1] and a[-1]<=b[-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()))
k=0
for i in range(n):
    if a[i]<b[i]:
        p=b[i]-a[i]
        a[i]+=(p+1)//2*2
        while p>0 and k<n:
            if a[k]-b[k]>p:
                b[k]+=p
                p=0
            elif a[k]-b[k]>0:
                b[k]=a[k]
                p-=a[k]-b[k]
            k+=1
if a==b:
    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
cnt=0
for i in range(n):
    k=a[i]-b[i]
    if k<0:
        k*=-1
        d-=k//2
        d+=k%2
        cnt+=k//2
    elif k>0:
        d+=k
d+=sum(b)-sum(a)-cnt
if d==0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l1=LI()
  l2=LI()

  sm1=sum(l1)
  sm2=sum(l2)

  nm=sm2-sm1
  if nm<0:
    return 'No'

  nm2=0
  for i in range(n):
    a=l1[i]
    b=l2[i]

    if a<b:
      _a=(b-a+1)//2
      l1[i]+=_a*2
      nm2+=_a

  for i in range(n):
    a=l1[i]
    b=l2[i]

    if a>b:
      _a=a-b
      nm2+=_a

  # print(nm,nm2)
  if nm<nm2:
    return 'No'

  return 'Yes'

# main()
print(main())

Submission status: Wrong Answer

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l1=LI()
  l2=LI()

  sm1=sum(l1)
  sm2=sum(l2)

  nm=sm2-sm1

  nm2=0
  for i in range(n):
    a=l1[i]
    b=l2[i]

    if a<b:
      _a=(b-a+1)//2
      l1[i]+=_a*2
      nm2+=_a

  for i in range(n):
    a=l1[i]
    b=l2[i]

    if a>b:
      _a=a-b
      nm2+=_a

  # print(nm,nm2)
  if nm<nm2:
    return 'No'

  return 'Yes'

# main()
print(main())

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
d=[]
for i in range(n):
    d.append(a[i]-b[i])

while(True):
    d.sort()
    if(d[0]>=0 and d[-1]>0):
        print("No")
        sys.exit()
    elif(d[-1]<=0):
        break
#    print(d)
    dmax=d[-1]
    d[0]+=2*dmax
    d[-1]=0
print("Yes")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
sum_a=sum(a)
sum_b=sum(b)
if(sum_a-sum_b<=0):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
cnt = 0
for a, b in zip(A, B):
    if a > b:
        cnt -= a - b
    if a < b:
        cnt += math.ceil((b - a) / 2)

if cnt < 0:
    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()))
cnt = 0
for a, b in zip(A, B):
    if a > b:
        cnt -= a - b
    if a < b:
        cnt += math.ceil((b - a) / 2)

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

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
cnt = 0
for a, b in zip(A, B):
    if a > b:
        cnt -= a - b
    if a < b:
        cnt += math.ceil((b - a) / 2)

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

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("Yes")
else:
    print("No")