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
import itertools
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque


# d = defaultdict(lambda: 0)
# setrecursionlimit(10**7)
# inf = float("inf")


##### stdin ####
def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_IL(): return LM(int,stdin)

##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))



##### main #####

def main():
	n = I()
	a = LI()
	b = LI()

	for i in range(n-1):
		diff = a[i]-b[i]

		if diff == 0:
			pass

		elif diff>0:
			b[i] += diff
			a[i+1] += 2*diff

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



	if a[:-1]==b[:-1]:
		if a[-1]<b[-1]:
			print("Yes")
		else:
			print("No")
	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()))
plus=0;minus=0
for i in range(N):
    c=a[i]-b[i]
    if c < 0:
        minus-=c
    elif c > 0:
        plus+=c

print("Yes" if minus >= plus*2+1 else "No")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys, functools

N = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
d = [b[i] - a[i] for i in range(N)]

op_cnt = sum(b) - sum(a)

if op_cnt < 0:
    print('No')
    sys.exit()


def q1(a, b):
    if b < 0:
        return a + b
    else:
        return a


if functools.reduce(q1, d, 0) * -1 > op_cnt:
    print('No')
    sys.exit()


def q2(a,b):
    if b > 0:
        return a + b // 2 + 1
    else:
        return a

if functools.reduce(q2, d, 0) > op_cnt:
    print('No')
    sys.exit()


print('Yes')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import math
tN = int(input())
ta = list(map(int, input().split()))
tb = list(map(int, input().split()))

a = []
b = []
N = tN
for i in range(tN):
    if ta[i] != tb[i]:
        a.append(ta[i])
        b.append(tb[i])
    else:
        N -= 1

ans = True
for i in range(N):
    s = b[i] - a[i]
    if s < 0:
        if i < N - 1:
            a[i + 1] -= 2 * s
        else:
            ans = False
    elif s > 1:
        if i < N - 1:
            b[i + 1] += s // 2
        else:
            ans = False

print(('No', 'Yes')[ans])

Submission status: Wrong Answer

Solution code:
N = int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
plus=0;minus=0
for i in range(N):
    c=a[i]-b[i]
    if c < 0:
        minus-=c
    elif c > 0:
        plus+=c

print("Yes" if minus > plus*2+1 else "No")

Submission status: Wrong Answer

Solution code:
n=int(input())

x=[int(i) for i in input().split()]
y=[int(i) for i in input().split()]
y_plus=0
xy_dif=0

for i in range(n):
    if x[i]<y[i] and (x[i]-y[i])%2==0:
        y_plus=int(0.5*(y[i]-x[i]))
        x[i]=y[i]
    elif x[i]<y[i] and (x[i]-y[i])%2==1:
        y_plus=int(0.5*(y[i]-x[i]+1))
        x[i]=y[i]+1
        xy_dif=xy_dif+1
    else:
        xy_dif=xy_dif+x[i]-y[i]

#print(x)
#print(y_plus,xy_dif)

if xy_dif<=y_plus:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

cnt = sum(b_list) - sum(a_list)

cnt_tmp = 0
for i in range(N):
    if a_list[i] < b_list[i]:
        cnt_tmp += ((b_list[i] - a_list[i]) // 2) + 1
        
if cnt_tmp > 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()))
plus=0;minus=0
for i in range(N):
    c=a[i]-b[i]
    if c < 0:
        minus-=c
    elif c > 0:
        plus+=c

print("Yes" if minus > plus*2 else "No")

Submission status: Wrong Answer

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

for i in range(n):
    if(a[i]<b[i]):
        ai += (b[i]-a[i])/2
    elif(a[i]>b[i]):
        bi += a[i]-b[i]

if(ai>bi and ai==int(ai)):
    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=0;minus=0
for i in range(N):
    c=a[i]-b[i]
    if c < 0:
        minus-=c
    elif c > 0:
        plus+=c

print("Yes" if minus >= plus*2 else "No")

Submission status: Wrong Answer

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

for i in range(n):
    if(a[i]<b[i]):
        ai += (b[i]-a[i])/2
    elif(a[i]>b[i]):
        bi += a[i]-b[i]

if(ai>bi):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
N = input()
a = input().split(" ")
b = input().split(" ")

a = map(int,a)
b = map(int,b)
# c = []
c =sum(a)-sum(b)
# print(c)
# for i in range(len(a)):
#     c += int(a[i])-int(b[i])
if c>=0:
    print("No")
elif abs(c)%2 == 0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import math
import itertools
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque


# d = defaultdict(lambda: 0)
# setrecursionlimit(10**7)
# inf = float("inf")


##### stdin ####
def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_IL(): return LM(int,stdin)

##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))



##### main #####

def main():
	n = I()
	a = LI()
	b = LI()

	for i in range(n-1):
		diff = a[i]-b[i]

		if diff == 0:
			pass

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

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

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

C = []

sum_a = sum(A)
sum_b = sum(B)

minus_sum = 0

while len(A) > 0:
    item = A.pop(0) - B.pop(0)
    C.append(item)
    if item < 0:
        minus_sum += item

#print sum_a, sum_b, C, sum(C), minus_sum

if sum_a < sum_b and sum(C) == (minus_sum - 1)/2:
    print 'Yes'
else:
    print 'No'

Submission status: Wrong Answer

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

    asum = sum(A)
    bsum = sum(B)
    if A == B:
        print(0)
    elif asum > bsum:
        print(-1)
    else:
        print(bsum - asum)

main()

Submission status: Wrong Answer

Solution code:
import numpy as np

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

sum_dif =  sum(B) - sum(A)

if sum_dif < 0:
    print("No")
elif sum_dif == 0:
    if A == B:
        print("Yes")
    else:
        print("No")
else:
    difference = list(np.array(A) - np.array(B))
    admissible_A = - sum([a for a in difference if a < 0]) // 2
    admissible_B = sum([b for b in difference if b > 0])
    
    surplus_A = (sum_dif - admissible_A)*2
    surplus_B = (sum_dif - admissible_B)
    
    if surplus_A == surplus_B:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())						# 5
a = sorted(list( map(int, input().split()) ))	# 1 2 3 4 5 ...(ソート付き)
b = sorted(list( map(int, input().split()) ))	# 1 2 3 4 5 ...(ソート付き)

#print("a", a)
#print("b", b)


ans='Yes'


for i in range(N):
	if a[i]>b[i]:
		ans='No'

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import math
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = True
for i in range(N):
    s = b[i] - a[i]
    if s < 0:
        if i < N - 1:
            a[i + 1] -= 2 * s
        else:
            ans = False
    elif s > 1:
        if i < N - 1:
            b[i + 1] += s // 2
        else:
            ans = False

print(('No', 'Yes')[ans])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
def inpl(): return tuple(map(int, input().split()))

N = int(input())
A = inpl()
B = inpl()

C = 0
D = 0

for a, b in zip(A, B):
    if b - a > 0:
        C += (b-a)
    else:
        D += (a-b)

if C >= 2*D:
    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 = [B[i]-A[i] for i in range(N)]

P = sum(filter(lambda x: x<0, C))
M = list(filter(lambda x: x>1, C))
M = list(map(lambda x: x%2, M))
M = sum(M)
if abs(M) <= abs(P):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n, a, b = input(), map(int, raw_input().split()), map(int, raw_input().split())
c = [a[i] - b[i] for i in xrange(n)]
print 'Yes' if -sum([x / 2 + 1 for x in c if x < 0]) >= sum([x for x in c if x > 0]) else 'No'

Submission status: Wrong Answer

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

flag = True

a = sorted(a)
b = sorted(b)
for i in range(len(a)):
    if a[i] > b[i]:
        flag = False
        break

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

d = b - a
n_sousa = np.sum(d)
n_sousa_b_need = np.sum(d[d < 0])
n_sousa_a_need = np.ceil(np.sum(d[d > 0])/2)
if n_sousa > n_sousa_b_need and n_sousa > n_sousa_a_need:
    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()))
ai = 0
bi = 0

for i in range(n):
    if(a[i]<b[i]):
        ai += (b[i]-a[i])%2
if(ai):
    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())))
if np.sum(b[a < b] - a[a < b]) > np.sum(a[b < a] - b[b < a]):
    print("No")
elif np.sum(a) > np.sum(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()))
aa = []
for k in a:
    if k in b:
        b.remove(k)
    else:
        aa.append(k)
flag = True

aa = sorted(aa)
b = sorted(b)
for i in range(len(aa)):
    if aa[i] > b[i]:
        flag = False
        break

if flag:
    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()))
    sortedA = sorted(A)
    sortedB = sorted(B)
    for i in range(N):
        if (sortedA[i]>sortedB[i]):
            print("No")
            return
    print("Yes")
    
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

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

d = b - a
n_sousa = np.sum(d)
n_sousa_b_need = np.sum(d[d < 0])
n_sousa_a_need = np.sum(d[d > 0])/2
if n_sousa > n_sousa_b_need and n_sousa > n_sousa_a_need:
    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[i]-B[i] for i in range(N)]

P = sum(filter(lambda x: x>0, C))
M = sum(filter(lambda x: x<-1, C))
if abs(M) > abs(2*P):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
alis = list(map(int,input().split()))
blis = list(map(int,input().split()))

sa = sum(alis)
sb = sum(blis)
dif = []
if sa >= sb:
	print("No")
else:
	for a,b in zip(alis,blis):
		dif.append(a-b)
	anum = 0
	bnum = 0
	for i in range(N):
		if dif[i] < 0:
			anum -= dif[i]
		else:
			bnum += dif[i]
	if (anum / 2) <= (sb - sa) and bnum <= (sb -sa):
		print("Yes")
	else:
		print("No")

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
lis1 = list(map(int,input().split()))
lis2 = list(map(int,input().split()))
if sum(lis1) > sum(lis2):
    print("No")
else:
    cou = sum(lis2) - sum(lis1)
    c = 0
    for i in range(n):
        c += math.ceil((lis2[i] - lis1[i]) / 2)
    if c > cou:
        print("No")
    else:
        for m in range(n):
            if lis1[m] == lis2[m]:
                print("Yes")
                break
            if m == n-1:
                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[i]-B[i] for i in range(N)]

P = sum(filter(lambda x: x>0, C))
M = sum(filter(lambda x: x<-1, C))
if abs(M) >= abs(2*P):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# coding=utf-8
N = int(input())
a = []
b = []

for x in input().split(" "):
    a.append(int(x))
for x in input().split(" "):
    b.append(int(x))

a.sort()
b.sort()

for (x,y) in zip(a,b):
    if x<=y:
        continue
    else:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

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

def cost(n):
    if n == 0:
        return [0, 0]
    elif n < 0:
        return [0, -n]
    elif n > 0 and n % 2 == 0:
        return [n//2, 0]
    else:
        return [(n+1)//2, 1]


PC = 0
MC = 0
for i in range(N):
    c = cost(b[i] - a[i])
    PC += c[0]
    MC += c[1]
if PC <= N and MC <= N and ((N-PC)*2 == (N-MC)):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = []
b = []

a = [int(num) for num in input().split(" ")]
b = [int(num) for num in input().split(" ")]

flag = False
aa = 0
bb = 0
m = 0
M = sum(b) - sum(a)
for _ in range(M):
    for ai in range(m,N):
        if a[ai] < b[ai]:
            a[ai] += 2
            aa = ai
            break
        if ai == N - 1:
            a[N - 1] += 2
            
    for bi in range(m,N):
        if b[bi] < a[bi]:
            b[bi] += 1
            bb = bi
            break
        if bi == N - 1:
            b[N - 1] += 1
            
    m = aa if aa < bb else bb
    if a == b:
        flag = True
        break

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

C = [A[i]-B[i] for i in range(N)]
if 0 in C:
    print("Yes")
    exit()
else:
    P = sum(filter(lambda x: x>0, C))
    M = sum(filter(lambda x: x<-1, C))
    if abs(M) >= abs(2*P):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np

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

c=b-a

if(sum(3*c-np.abs(c))>=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()))
guusuu=0
kisuu=0
zero=0
for i in range(n):
    if (a[i]-b[i])%2==0 and (a[i]-b[i])!=0:
        guusuu+=abs(a[i]-b[i])//2
    elif (a[i]-b[i])==0:
        zero+=1
    else:
        kisuu+=abs(a[i]-b[i])
for i in range(0,zero+1):
    if guusuu//2+i==kisuu+i*2:
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

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

largeA = 0
largeB = 0
for i in range(N):
  if A[i] > B[i]:
    largeA += A[i] - B[i]
  elif B[i] > A[i]:
    largeB += B[i] - A[i]

dsum = sum(B) - sum(A)
if dsum >= 0 and largeB/2 <= dsum and largeA <= dsum:
  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()

limit = sum(b) - sum(a)
diff = [bt - at for at, bt in zip(a, b)]

est = 0
for d in diff:
    if 0 < d:
        est += d
    elif d < 0:
        est += d * 2

if est == limit and 0 <= limit:
    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 = sum(B) - sum(A)

    if d < 0:
        print('No')
        return

    C = [a - b for a, b in zip(A, B)]
    m = sum((x for x in C if x < 0))

    # print(d, m)

    if abs(m) > d * 2:
        print('No')
    else:
        print('Yes')


main()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
guusuu=0
kisuu=0
zero=0
for i in range(n):
    if (a[i]-b[i])%2==0 and (a[i]-b[i])!=0:
        guusuu+=abs(a[i]-b[i])//2
    elif (a[i]-b[i])==0:
        zero+=1
    else:
        kisuu+=abs(a[i]-b[i])
for i in range(0,zero):
    if guusuu//2+i==kisuu+i*2:
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

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

surplus = 0
deficit = 0
for a,b in zip(A,B):
  if a > b:
    surplus += a-b
  else:
    deficit += b-a

max_op = deficit-surplus
if max_op < 0:
  print('No')
elif deficit > 2*max_op or surplus > max_op:
  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.sort()
b.sort()

limit = sum(b) - sum(a)
diff = [bt - at for at, bt in zip(a, b)]

est = 0
for d in diff:
    if 0 < d:
        est += d
    elif d < 0:
        est += d * 2

if est == limit:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
lis1 = list(map(int,input().split()))
lis2 = list(map(int,input().split()))
if sum(lis1) > sum(lis2):
    print("No")
else:
    cou = sum(lis2) - sum(lis1)
    c = 0
    for i in range(n):
        while lis1[i] < lis2[i]:
            lis1[i] += 2
            c += 1
    if c < cou:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
# coding=utf-8
N = int(input())
a = []
b = []

for x in input().split(" "):
    a.append(int(x))
for x in input().split(" "):
    b.append(int(x))

if min(a)>=min(b):
    print("No")
    exit()

a.sort()
b.sort()

for (x,y) in zip(a,b):
    if x<=y:
        continue
    else:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
from operator import sub

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

As.sort()
Bs.sort()

if min(map(sub, Bs, As)) >= 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()))

da = 0
db = 0
for i in range(n):
    if a[i] > b[i]:
        da += a[i] - b[i]
    elif a[i] < b[i]:
        db += b[i] - a[i]

if da * 2 <= db:
    ans = "Yes"
else:
    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()

limit = sum(b) - sum(a)
diff = [bt - at for at, bt in zip(a, b)]

est = 0
for d in diff:
    if 0 < d:
        est += d
    elif d < 0:
        est -= d

if est == limit:
    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()))
guusuu=0
kisuu=0
for i in range(n):
    if (a[i]-b[i])%2==0 and (a[i]-b[i])!=0:
        guusuu+=abs(a[i]-b[i])//2
    else:
        kisuu+=1
if guusuu==kisuu:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
def LI(): return list(map(int, input().split()))
def LS(): return input().split()
def I(): return int(input())
def S(): return input()

n = I()
a = LI()
b = LI()
plus = 0
minus = 0
for i in range(n):
    c = a[i] - b[i]
    if c > 0:
        plus += c
    else:
        minus += c
if minus + 2 * plus <= 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()))
c = 0
for i in range(n):
    if a[i] < b[i]:
        c = c + (b[i] - a[i] + 1) // 2 + (b[i] - a[i]) % 2
    if a[i] > b[i]:
        c = c + a[i] - b[i]
d = 0
for i in range(n):
    d = d + b[i] - a[i]
if c <= d:
    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()]

total_do=sum(b)-sum(a)
must_do_a=0
must_do_b=0

for i in range(N):
	dist=a[i]-b[i]
	if dist<0:
		dist=-dist
		must_do_a+=int(dist/2)
		if dist%2!=0:
			must_do_b+=1
	elif dist>0:
		must_do_b+=dist
left_a=total_do-must_do_a
left_b=total_do-must_do_b

if total_do>=0 and must_do_a>=must_do_b and left_a*2==left_b:
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
N = input()
a = input().split(" ")
b = input().split(" ")

# c = []
c =0
for i in range(len(a)):
    c += int(a[i])-int(b[i])

if abs(c)%2 == 0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().strip().split()))
    B = list(map(int, input().strip().split()))
    sousa_A, sousa_B = 0, 0
    if sum(A) > sum(B):
        print("No")
    elif all(a==b for a, b in zip(A, B)):
        print("Yes")
    for a, b in zip(A, B):
        if a > b:
            sousa_B += a-b
        if b > a:
            sousa_A += (b-a)//2
    if sousa_A == sousa_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(' ')))
a1=0
b1=0
cnt=0
for i in range(0,n):
    if a[i]==b[i]:
        cnt+=1
    elif a[i]>b[i]:
        b1+=a[i]-b[i]
    else:
        if (b[i]-a[i])%2==0:
            a1+=(b[i]-a[i])//2
        else:
            a1+=(b[i]+1-a[i])//2
            b1+=1
if a1==b1:
    print("Yes")
elif a1>b1 and cnt>0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
p = sum(P)
q = sum(Q)
if (q - p) % N == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import random
import functools
import itertools
import math

R = lambda type_ = "int": list(map(eval(type_), input().split(' ')))

n = int(input())
a = R()
b = R()

pos, neg = 0, 0

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

#print('{} {}'.format(pos, neg))
print('Yes' if pos >= 2 * neg else '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()]

total_do=sum(b)-sum(a)
must_do_a=0
must_do_b=0

for i in range(N):
	dist=a[i]-b[i]
	if dist<0:
		dist=-dist
		must_do_a+=int(dist/2)
		if dist%2!=0:
			must_do_b+=1
	elif dist>0:
		must_do_b+=dist
left_a=total_do-must_do_a
left_b=total_do-must_do_b

if total_do>=0 and left_a>=0 and left_b>=0 and left_a*2==left_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()))
k = 0
for i in a:
    if i % 2 == 0:
        k += 1
for j in b:
    if j % 2 == 1:
        k -= 1

if k == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

import numpy as np

n = int(raw_input())
a = map(int,raw_input().split())
b = map(int,raw_input().split())

a_sum = sum(a)
b_sum = sum(b)

x = b_sum-a_sum

a_over = 0
b_over = 0

for i in range(n):
    check = b[i] - a[i]
    if check > 0:
        b_over += check
    else:
        a_over -= check

#print a_over
#print b_over

if a_over <= x and b_over <= 2*x:
    ans = "Yes"
else:
    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(" ")))

x = sum(a)
y = sum(b)

if x>y or (x-y)%2==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()))
k = 0
for i in a:
    if i % 2 == 0:
        k += 1
for j in b:
    if j % 2 == 1:
        k -= 1

if k == 0:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = []
b = []

a = [int(num) for num in input().split(" ")]
b = [int(num) for num in input().split(" ")]

flag = False
M = sum(b) - sum(a)
for _ in range(M):
    for ai in range(N):
        if a[ai] < b[ai]:
            a[ai] += 2
            break
    for bi in range(N):
        if b[bi] < a[bi]:
            b[bi] += 1
            break
    if a == b:
        flag = True
        break

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 = sum(a)
B = sum(b)
s = A - B

if s < 0:
    if abs(s) == N:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
#-*- coding: utf-8 -*-

from collections import defaultdict
from math import factorial as f
from fractions import gcd as g

N = int (raw_input ())
a = [int (i) for i in raw_input ().split ()]
b = [int (i) for i in raw_input ().split ()]
a.sort ()
b.sort ()
ok = True
for i in range (N):
    if a [i] > b [i]:
        ok = False
        break
print ["No", "Yes"][ok]

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

total_do=sum(a)-sum(b)
must_do_a=0
must_do_b=0

for i in range(N):
	dist=a[i]-b[i]
	if dist<0:
		dist=-dist
		must_do_a+=int(dist/2)
		if dist%2!=0:
			must_do_b+=1
	elif dist>0:
		must_do_b+=dist

if must_do_a>=must_do_b:
	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()]

total_do=sum(a)-sum(b)
must_do_a=0
must_do_b=0

for i in range(N):
	dist=a[i]-b[i]
	if dist<0:
		dist=-dist
		must_do_a+=int(dist/2)
		if dist%2!=0:
			must_do_b+=1
	elif dist>0:
		must_do_b+=dist

if must_do_a>=must_do_b:
	print("YES")
else:
	print("NO")

Submission status: Wrong Answer

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

K = sum(B) - sum(A)
C = 0
for i in range(N):
    p = B[i] - A[i]
    if p > 0:
        C += (p//2) + (p%2)
    else:
        C += -p
if K >= 0 and C == 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()

for a,b in zip(A,B):
    if a > b:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
p = sum(P)
q = sum(Q)
if q - p == N or q - p == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
p = sum(P)
q = sum(Q)
if q - p == 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()))
a.sort()
b.sort()
check = True
for i in range(n):
	if a[i] > b[i]:
		check = False
if check:
	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('Yes')
else:
  print('No')

Submission status: Time Limit Exceeded

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    B = list(map(int, input().split()))
    B.sort()
    sum_a = sum(A)
    sum_b = sum(B)
    k = sum_b - sum_a

    now = 0
    while now < N and A[now] == B[now]:
        now += 1

    while k > 0 and now < N:
        while now < N and  A[now] == B[now]:
            now += 1
        
        if now < N:
            A[now] += 2
            B[now] += 1
            k -= 1
            if A[now] == B[now]:
                now += 1
    
    if now == N:
        print("Yes")
    else:
        print("No")
        
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

na, nb = 0, 0

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

for i in range(N):
    while a[i]!= b[i]:
        if suma + na >= sumb + nb:
            jdg = True
            break
        if a[i] > b[i]:
            b[i] += 1
            if nb > 0: nb -= 1
            na += 2
        else:
            a[i] += 2
            if na >= 2: na -= 2
            nb += 1
    if jdg: break
print('No' if jdg else 'Yes')