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:
def after_exp():
    N = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    count = sum(b) - sum(a)
    if count < 0: return print('No')

    Amove = 0
    Bmove = 0

    for i in range(N):
        if a[i] > b[i]:
            Amove += a[i] - b[i]
        else:
            Bmove += (b[i] - a[i]) //2
    if a == b: return print('Yes')

    if Bmove > Amove:
        return print('No')
    else:
        return print('Yes')


# main()
after_exp()

Submission status: Wrong Answer

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

    count = sum(b) - sum(a)
    mina = 0
    minb = 0

    for i in range(N):
        if a[i] > b[i]:
            minb += a[i] - b[i]
        else:
            mina += (b[i] - a[i] // 2)
    if a == b: return print('Yes')
    if count < 0: return print('No')
    if minb > mina:
        return print('No')
    else:
        return print('Yes')


# main()
after_exp()

Submission status: Wrong Answer

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

    count = sum(b) - sum(a)
    mina = 0
    minb = 0

    for i in range(N):
        if a[i] > b[i]:
            minb += a[i] - b[i]
        else:
            mina += (b[i] - a[i] // 2)
    if a == b: return print('Yes')
    if minb > count: return print('No')
    if minb > mina:
        return print('No')
    else:
        return print('Yes')


# main()
after_exp()

Submission status: Wrong Answer

Solution code:
def main():
    def is_even(n):
        return n % 2 == 0

    def is_odd(n):
        return not is_even(n)

    N = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    if a == b:
        return print('Yes')

    d = [b[i] - a[i] for i in range(N)]
    dif_cnt = 0
    for i in range(N):
        if is_even(a[i]) and is_even(b[i]):
            continue
        if is_odd(a[i]) and is_odd(b[i]):
            continue
        dif_cnt += 1

    sum_d = sum(d)
    if sum_d <= 0:
        return print('No')
    if sum_d % 3 == 0:
        if dif_cnt % 2 == 1 and sum_d > dif_cnt and dif_cnt % 2 == 1:
            return print('Yes')
        elif dif_cnt % 2 == 0 and sum_d > dif_cnt and dif_cnt % 2 == 0:
            return print('Yes')
    return print('No')


def after_exp():
    N = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    count = sum(b) - sum(a)
    mina = 0
    minb = 0

    for i in range(N):
        if a[i] > b[i]:
            minb += a[i] - b[i]
        else:
            mina += b[i] - a[i]
    if a == b: return print('Yes')
    if minb > count: return print('No')
    if mina % 2 == 0:
        if mina // 2 > count:
            return print('No')
    else:
        if (mina // 2) + 1 > count:
            return print('No')
    return print('Yes')


# main()
after_exp()

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
length = int(input())
a = [int(i) for i in input().split()]
b =  [int(i) for i in input().split()]
diff = sum(b) -sum(a)
if(sum(b) == sum(a)):
        flag = 0
        for i in range(0,len(a)):
                if(a[i] != b[i]):
                        flag = 1
        if(flag ==0):
                print("Yes")
                sys.exit()
if(sum(b) < sum(a) or len(a) != len(b)):
        print("No")
        sys.exit()
else:
        tmp = 0
        tmp2 = 0
        for i in range(0,length):
                if(b[i] > a[i]):
                        tmp+=(b[i] - a[i])
                if(a[i] > b[i]):
                        tmp2+=(a[i] -b[i])
        if(diff == 0 and tmp == 0 and tmp2 == 0):
                print("Yes")
        elif(tmp > 2*diff or tmp2 > diff):
                print("No")
        else:
                print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
length = int(input())
a = [int(i) for i in input().split()]
b =  [int(i) for i in input().split()]
diff = sum(b) -sum(a)
if(sum(b) == sum(a)):
        flag = 0
        for i in range(0,len(a)):
                if(a[i] != b[i]):
                        flag = 1
        if(flag ==0):
                print("Yes")
                sys.exit()
if(sum(b) < sum(a) or len(a) != len(b)):
        print("No")
        sys.exit()
else:
        tmp = 0
        tmp2 = 0
        for i in range(0,length):
                if(b[i] > a[i]):
                        tmp+=b[i] - a[i]
                if(a[i] > b[i]):
                        tmp2+=a[i] -b[i]
        if(diff == 0 and tmp == 0 and tmp2 == 0):
                print("Yes")
        elif(tmp > 2*diff or tmp2 > diff):
                print("No")
        else:
                print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
length = int(input())
a = [int(i) for i in input().split()]
b =  [int(i) for i in input().split()]
diff = sum(b) -sum(a)
if(sum(b) == sum(a)):
        flag = 0
        for i in range(0,len(a)):
                if(a[i] != b[i]):
                        flag = 1
        if(flag ==0):
                print("Yes")
                sys.exit()
if(sum(b) < sum(a)):
        print("No")
        sys.exit()
else:
        tmp = 0
        tmp2 = 0
        for i in range(0,length):
                if(b[i] > a[i]):
                        tmp+=b[i] - a[i]
                if(a[i] > b[i]):
                        tmp2+=a[i] -b[i]
        if(diff == 0 and tmp == 0 and tmp2 == 0):
                print("Yes")
        elif(tmp > 2*diff or tmp2 > diff):
                print("No")
        else:
                print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
n = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
b =  [int(i) for i in input().split()]
diff = sum(b) -sum(a)
if(sum(b) == sum(a)):
        flag = 0
        for i in range(0,len(a)):
                if(a[i] != b[i]):
                        flag = 1
        if(flag ==0):
                print("Yes")
                sys.exit()
if(sum(b) < sum(a)):
        print("No")
        sys.exit()
else:
        tmp = 0
        tmp2 = 0
        for i in range(0,len(a)):
                if(b[i] > a[i]):
                        tmp+=b[i] - a[i]
                if(a[i] > b[i]):
                        tmp2+=a[i] -b[i]
        if(diff == 0 and tmp == 0 and tmp2 == 0):
                print("Yes")
        elif(tmp > 2*diff or tmp2 > diff):
                print("No")
        else:
                print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
n = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
b =  [int(i) for i in input().split()]
diff = sum(b) -sum(a)
if(sum(b) == sum(a)):
        flag = 0
        for i in range(0,len(a)):
                if(a[i] != b[i]):
                        flag = 1
        if(flag ==0):
                print("Yes")
                sys.exit()
if(sum(b) < sum(a)):
        print("No")
        sys.exit()
else:
        tmp = 0
        tmp2 = 0
        for i in range(0,len(a)):
                if(b[i] > a[i]):
                        tmp+=b[i] - a[i]
                if(a[i] > b[i]):
                        tmp2+=a[i] -b[i]
        if(tmp > 2*diff or tmp2 > diff):
                print("No")
        else:
                print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
n = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
b =  [int(i) for i in input().split()]
diff = sum(b) -sum(a)
if(sum(b) == sum(a)):
        flag = 0
        for i in range(0,len(a)):
                if(a[i] != b[i]):
                        flag = 1
        if(flag ==0):
                print("Yes")
                sys.exit()
if(sum(b) < sum(a)):
        print("No")
        sys.exit()
else:
        tmp = 0
        tmp2 = 0
        for i in range(0,len(a)):
                if(b[i] > a[i]):
                        tmp+=b[i] - a[i]
                if(a[i] > b[i]):
                        tmp2+=a[i] -b[i]
        if(tmp/2.0 > diff or tmp2 > diff):
                print("No")
        else:
                print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
n = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
b =  [int(i) for i in input().split()]
diff = sum(b) -sum(a)
if(sum(b) == sum(a)):
        flag = 0
        for i in range(0,len(a)):
                if(a[i] != b[i]):
                        flag = 1
        if(flag ==0):
                print("Yes")
                sys.exit()
if(sum(b) < sum(a)):
        print("No")
        sys.exit()
else:
        tmp = 0
        tmp2 = 0
        for i in range(0,len(a)):
                if(b[i] > a[i]):
                        tmp+=b[i] - a[i]
                if(a[i] > b[i]):
                        tmp2+=a[i] -b[i]
        if(tmp/2.0 > diff or tmp2/2.0 > diff):
                print("No")
        else:
                print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
n = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
b =  [int(i) for i in input().split()]
diff = sum(b) -sum(a)
if(sum(b) == sum(a)):
        flag = 0
        for i in range(0,len(a)):
                if(a[i] != b[i]):
                        flag = 1
        if(flag ==0):
                print("Yes")
                sys.exit()
if(sum(b) < sum(a)):
        print("No")
        sys.exit()
else:
        tmp = 0
        tmp2 = 0
        for i in range(0,len(a)):
                if(b[i] > a[i]):
                        tmp+=b[i] - a[i]
                if(a[i] > b[i]):
                        tmp2+=a[i] -b[i]
        if(tmp < tmp2 or tmp/2.0 > diff or tmp2/2.0 > diff):
                print("No")
                sys.exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
n = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
b =  [int(i) for i in input().split()]
diff = sum(b) -sum(a)
if(sum(b) == sum(a)):
        flag = 0
        for i in range(0,len(a)):
                if(a[i] != b[i]):
                        flag = 1
        if(flag ==0):
                print("Yes")
                sys.exit()
if(sum(b) < sum(a)):
        print("No")
        sys.exit()
else:
        tmp = 0
        tmp2 = 0
        for i in range(0,len(a)):
                if(b[i] > a[i]):
                        tmp+=b[i] - a[i]
                if(a[i] > b[i]):
                        tmp2+=a[i] -b[i]
        if(tmp/2.0 > diff or tmp2/2.0 > diff):
                print("No")
                sys.exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
n = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
b =  [int(i) for i in input().split()]
diff = sum(b) -sum(a)
if(sum(b) < sum(a)):
        print("No")
        sys.exit()
else:
        tmp = 0
        tmp2 = 0
        j = 0
        count = 0
        for i in range(0,len(a)):
                if(b[i] > a[i]):
                        tmp+=b[i] - a[i]
                if(a[i] > b[i]):
                        tmp2+=a[i] -b[i]
        if(tmp/2.0 > diff or tmp2/2.0 > diff):
                print("No")
                sys.exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
n = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
b =  [int(i) for i in input().split()]
diff = sum(b) -sum(a)
if(sum(b) < sum(a)):
        print("No")
        sys.exit()
else:
        tmp = 0
        tmp2 = 0
        j = 0
        count = 0
        for i in range(0,len(a)):
                if(b[i] > a[i]):
                        tmp+=b[i] - a[i]
        if(tmp/2.0 > diff ):
                print("No")
                sys.exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
n = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
b =  [int(i) for i in input().split()]
diff = sum(b) -sum(a)
if(sum(b) < sum(a)):
        print("No")
        sys.exit()
else:
        tmp = 0
        tmp2 = 0
        j = 0
        count = 0
        for i in range(0,len(a)):
                tmp+=b[i] - a[i]
        if(tmp != diff or tmp%len(a)!=0):
                print("No")
                sys.exit()

print("Yes")

Submission status: Wrong Answer

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

    count = sum(b) - sum(a)
    mina = 0
    minb = 0

    for i in range(N):
        if a[i] > b[i]:
            minb += a[i] - b[i]
        else:
            mina += b[i] - a[i]
    if a == b: return print('Yes')
    if mina % 2 == 0:
        if mina // 2 > count:
            return print('No')
    else:
        if (mina // 2) + 1 > count:
            return print('No')
    return print('Yes')


# main()
after_exp()

Submission status: Wrong Answer

Solution code:
def after_exp():
    N = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    count = sum(a) - sum(b)
    mina = 0
    minb = 0

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

    if minb > count: return print('No')
    if (mina //2) + 1 > count: return print('No')
    return print('Yes')


# main()
after_exp()

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

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))
    man_required_A = sum([math.ceil(- a/2) for a in difference if a < 0])
    man_required_B = sum([b for b in difference if b > 0])
    
    admissible = sum_dif - man_required_A - man_required_B
    
    if admissible > 0:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

suma = sumb = num = 0
for i in range(N):
    suma += A[i]
    sumb += B[i]
    if A[i] < B[i]:
        num += (B[i] - A[i]) // 2

if A == B:
    print("Yes")
else:
    if suma >= sumb:
        print("No")
    else:
        if num > sumb - suma:
            print("No")
        else:
            print("Yes")

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

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))
    man_required_A = sum([math.ceil(- a/2) for a in difference if a < 0])
    man_required_B = sum([b for b in difference if b > 0])
    
    admissible_A = sum_dif - man_required_A
    admissible_B = sum_dif - man_required_B
    
    if admissible_A > 0 and admissible_B > 0:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

suma = sumb = greater = lesser = 0
for i in range(N):
    suma += A[i]
    sumb += B[i]
    if A[i] > B[i]:
        greater += A[i] - B[i]
    else:
        lesser += B[i] - A[i]

if A == B:
    print("Yes")
else:
    if suma >= sumb:
        print("No")
    else:
        if greater > lesser // 2:
            print("No")
        else:
            print("Yes")

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 = int((sum_dif - admissible_A)*2)
    surplus_B = (sum_dif - admissible_B)
    
    if surplus_A == surplus_B and surplus_A > 0:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

suma = sumb = greater = 0
for i in range(N):
    suma += A[i]
    sumb += B[i]
    if A[i] > B[i]:
        greater += A[i] - B[i]

if A == B:
    print("Yes")
else:
    if suma >= sumb:
        print("No")
    else:
        if greater > sumb - suma:
            print("No")
        else:
            print("Yes")

Submission status: Wrong Answer

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

suma = sumb = great = equal = 0
for i in range(N):
    suma += A[i]
    sumb += B[i]
    if A[i] > B[i]:
        great += 1
    elif A[i] == B[i]:
        equal += 1

if A == B:
    print("Yes")
else:
    if suma >= sumb:
        print("No")
    else:
        if great > (N - equal) // 2:
            print("No")
        else:
            print("Yes")

Submission status: Wrong Answer

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

suma = sumb = great = 0
for i in range(N):
    suma += A[i]
    sumb += B[i]
    if A[i] > B[i]:
        great += 1

if A == B:
    print("Yes")
else:
    if suma >= sumb:
        print("No")
    else:
        if great >= N // 2:
            print("No")
        else:
            print("Yes")

Submission status: Wrong Answer

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

suma = sumb = great = 0
for i in range(N):
    suma += A[i]
    sumb += B[i]
    if A[i] > B[i]:
        great += 1

if A == B:
    print("Yes")
else:
    if suma >= sumb:
        print("No")
    else:
        if great > N // 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()))
if a == b:
    print("Yes")
elif sum(a) >= sum(b):
    print("No")
else:
    x = 0
    flg = 0
    for i in range(N):
        if b[i]-a[i] > 0:
            x += b[i]-a[i]
            if (b[i]-a[i])%2 == 1:
                flg = 1
    if flg == 1:
        x += 1
    if x/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()))
if a == b:
    print("Yes")
elif sum(a) >= sum(b):
    print("No")
else:
    x = 0
    flg = 0
    for i in range(N):
        if b[i]-a[i] > 0:
            x += b[i]-a[i]
            if (b[i]-a[i])%2 == 1:
                flg = 1
    if x/2 < (sum(b)-sum(a)):
        print("Yes")
    elif x/2 == (sum(b)-sum(a)) and flg == 0:
        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:
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)]
d = sum(filter(lambda x:x<0, c))+2*sum(filter(lambda x:x>0, c))
if d > 0:
    print("No")
    exit()
elif d < 0:
    print("Yes")
    exit()
while sum(c) < 0:
    i,j,m = 0,0,0
    f_i,f_j = False,False
    for k in range(n):
        if c[k] == -1 and not f_i:
            i = k
            j = k
            f_i = True
            f_j = True
        if c[k] < -1 and not f_i:
            i = k
            f_i = True
        if c[k] > 0 and not f_j:
            j = k
            f_j = True
        if c[k] == 0:
            m = k
        if f_i and f_j:
            break
    if not f_j:
        j = m
    c[i] += 2
    c[j] -= 1
if len(list(filter(lambda x:x!=0, c))) > 0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
n = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
b =  [int(i) for i in input().split()]
diff = sum(b) -sum(a)
if(sum(b) < sum(a)):
        print("No")
        sys.exit()
else:
        tmp = 0
        tmp2 = 0
        j = 0
        for i in range(0,len(a)):
                if(b[i] > a[i]):
                        tmp+=b[i] - a[i]
        if(tmp > 2*diff):
                print("No")
                sys.exit()
        while(j < diff):
                flag = 0
                for i in range(0,len(a)):
                        if(b[i] > a[i]):
                                a[i]+=2
                                min_i = 0
                                max_N = float('inf')
                                for j in range(0,len(b)):
                                        if(max_N > b[j]):
                                                max_N = b[j]
                                                min_i = j
                                b[min_i]+=1
                                j+=1
                                break
                        else:
                                flag = 1
                if(flag):
                        print("No")
                        sys.exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
n = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
b =  [int(i) for i in input().split()]
diff = sum(b) -sum(a)
if(sum(b) < sum(a)):
        print("No")
        sys.exit()
else:
        tmp = 0
        tmp2 = 0
        j = 0
        while(j < diff):
                flag = 0
                for i in range(0,len(a)):
                        if(b[i] > a[i]):
                                a[i]+=2
                                min_i = 0
                                max_N = float('inf')
                                for j in range(0,len(b)):
                                        if(max_N > b[j]):
                                                max_N = b[j]
                                                min_i = j
                                b[min_i]+=1
                                j+=1
                                break
                        else:
                                flag = 1
                if(flag):
                        print("No")
                        sys.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 P == Q:
    print("Yes")
else:
    m = 0
    l = 0
    for i in range(N):
        if P[i] - Q[i] > 0:
            if (P[i] - Q[i]) % 2 == 1:
                #p += (P[i] - Q[i]) * 2
                m += (P[i] - Q[i] + 1) // 2
                l += 1
            else:
                #p += (P[i] - Q[i])
                m += (P[i] - Q[i]) // 2
        elif P[i] - Q[i] < 0:
            #q += (Q[i] - P[i])
            l += (Q[i] - P[i])
    
    a = p + m * 2 + l
    b = q + m + l 
    if a > b:
        print("No")
    elif a == b:
        print("Yes")
    else:
        if m != 0:
            if l % m == 0:
                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(' ')))
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
print("Yes")

Submission status: Wrong Answer

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

suma = sumb = 0
for i in range(N):
    suma += A[i]
    sumb += B[i]

if A == B:
    print("Yes")
else:
    if suma >= sumb:
        print("No")
    else:
        if abs(suma - sumb) % 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()))
c = [a[i]-b[i] for i in range(n)]
if sum(filter(lambda x:x<0, c))+2*sum(filter(lambda x:x>0, c)) > 0:
    print("No")
else:
    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 P == Q:
    print("Yes")
else:
    m = 0
    l = 0
    for i in range(N):
        if P[i] - Q[i] > 0:
            if (P[i] - Q[i]) % 2 == 1:
                #p += (P[i] - Q[i]) * 2
                m += (P[i] - Q[i] + 1) // 2
                l += 1
            else:
                #p += (P[i] - Q[i])
                m += (P[i] - Q[i]) // 2
        elif P[i] - Q[i] < 0:
            #q += (Q[i] - P[i])
            l += (Q[i] - P[i])
    
    a = p + m * 2 + l
    b = q + m + l 
    if a > b:
        print("No")
    elif a == b:
        print("Yes")
    else:
        if m != 0:
            if l % m == 0:
                print("Yes")
            else:
                print("No")
        else:
                print("Yes")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split(' ')))
b=list(map(int,input().split(' ')))
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 and cnt<n-1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

li = [x-y for (x,y) in zip(a,b)]

s_p = 0
s_m = 0



for i in range(len(li)):
     if li[i] > 0:
       s_p += li[i]   
     elif li[i] < 0:
       s_m += li[i]
     elif li[i] == 0:
          pass

if s_p % 2 == 1 and abs(s_m) % 2 == 0:
     print('Yes')
else:
     print('No')

Submission status: Wrong Answer

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

li = [x-y for (x,y) in zip(a,b)]

s_p = 0
s_m = 0



for i in range(len(li)):
     if li[i] > 0:
       s_p += li[i]   
     elif li[i] < 0:
       s_m += li[i]
     elif li[i] == 0:
          pass

if s_p % 2 == 1 and s_m % 2 == 0:
     print('Yes')
else:
     print('No')

Submission status: Wrong Answer

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

suma = sumb = 0
for i in range(N):
    suma += A[i]
    sumb += B[i]

if A == B:
    print("Yes")
else:
    if suma >= sumb:
        print("No")
    else:
        if (suma + sumb) % 3 == 0:
            print("Yes")
        else:
            print("No")

Submission status: Wrong Answer

Solution code:
import sys

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

for x in zip(A,B):
    if (x[1]-x[0]) < 0:
        print("No")
        break
else:
    print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

suma = sumb = 0
for i in range(N):
    suma += A[i]
    sumb += B[i]

if A == B:
    print("Yes")
else:
    if suma >= sumb:
        print("No")
    else:
        if abs(suma - sumb) >= N:
            print("No")
        else:
            print("Yes")

Submission status: Wrong Answer

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

li = [x-y for (x,y) in zip(a,b)]

s_p = 0
s_m = 0

for i in range(len(li)):
     if li[i] > 0:
       s_p += li[i]   
     elif li[i] < 0:
       s_m += li[i]
     elif li[i] == 0:
          pass

if abs(s_m) % 2 == 0:
     if (abs(s_p) + (abs(s_m) / 2)) <= N:
          print('Yes')
     else:
          print('No')
else:
     print('No')

Submission status: Wrong Answer

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

As.sort(reverse=True)
Bs.sort(reverse=True)

for iB in range(N):
    if As[iB] > Bs[iB]:
        d = As[iB] - Bs[iB]
        Bs[iB] += d
        rest = d * 2
        for iA in range(iB + 1, N):
            d = min(rest, max(0, (Bs[iA] - As[iA]) // 2 * 2))
            As[iA] += d
            rest -= d
            if rest == 0: break
        if rest > 0:
            print('No')
            exit()
    elif As[iB] < Bs[iB]:
        d = Bs[iB] - As[iB]
        As[iB] += d * 2
        Bs[iB] += d

print('Yes')

Submission status: Wrong Answer

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

s = sorted(b[i] - a[i] for i in range(N))
plus = [x for x in s if x > 0]
minus = [x for x in s if x < 0]
while len(plus) > 0 and len(minus) > 0:
    m = min(len(plus), len(minus))
    for i in range(m):
        plus[-1 - i] += 2 * minus[i]
    s = sorted(plus + minus[m:])
    plus = [x for x in s if x > 0]
    minus = [x for x in s if x < 0]
print(('No', 'Yes')[len(plus) > len(minus)])