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
input = sys.stdin.readline

n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

cnt = sum(b) - sum(a)
if cnt <= 0:
    print("No")
    sys.exit()
diff1 = [] # a > b
diff2 = [] # b > a
for i, j in zip(a, b):
    if i > j:
        diff1.append(i - j)
    elif j > i:
        diff2.append(j - i)

if cnt < sum(diff1):
    print("No")
    sys.exit()
else:
    cnt -= sum(diff1)

a_add = cnt + sum(diff1) # 2を足す
b_add = cnt # 1を足す

c = []
for i in diff2:
    if i % 2 == 0:
        a_add -= i//2
    else:
        c.append(1)
        a_add -= (i - 1)//2
if b_add + sum(c) == 2*a_add:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

    asmall=0
    bsmall=0
    for a,b in zip(A,B):
        asmall+=max(0, b-a)
        bsmall+=max(0, a-b)
    if asmall < bsmall*2:
        print('No')
    else:
        if (sum(B)-sum(A))&1:
            if sum(B)&1==sum(A)&1:
                print('No')
            else:
                print('Yes')
        else:
            if sum(B)&1==sum(A)&1:
                print('Yes')
            else:
                print('No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
b = inpl()
res = 0
for i in range(n):
    if a[i] > b[i]:
        res += (b[i] - a[i]) * 2
    elif b[i] - a[i] > 1:
        res += b[i] - a[i]
print('Yes' if res >= 0 else 'No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=sum(b)-sum(a)
co=0
for i in range(n):
    if a[i]==b[i]:
        continue
    elif a[i]>b[i]:
        co+=a[i]-b[i]
    else:
        co+=(b[i]-a[i]+1)//2
print('Yes' if c>=co else 'No')

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
b = inpl()
res = 0
for i in range(n):
    if a[i] > b[i]:
        res += (b[i] - a[i]) * 2
    elif a[i] < b[i]:
        res += b[i] - a[i]
print('Yes' if res >= 0 else 'No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ret = [0] * n
for i in range(n):
    ret[i] = b[i] - a[i]
ret = sorted(ret)

cnt = 0
for i, val in enumerate(ret):
    if val < 0:
        cnt += abs(val)
        ret[i] = 0
    elif val % 2 == 1:
        cnt += 1
        ret[i] -= 1

for i, val in enumerate(ret):
    cnt -= val // 2
if cnt <= 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=sum(b)-sum(a)
co=0
for i in range(n):
    if a[i]>b[i]:
        co+=a[i]-b[i]
    else:
        co+=(b[i]-a[i]+1)//2
print('Yes' if c==co else 'No')

Submission status: Wrong Answer

Solution code:
import math

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

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

num_a = 0
num_b = 0
for i in range(n):
    if a[i] > b[i]:
        num_b += a[i] - b[i]
    elif b[i] > a[i]:
        num_a += math.ceil((b[i]-a[i])/2)
        num_b += (b[i]-a[i]) % 2

if num_b*2 == num_a:
    print('Yes')
elif num_b == 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=sum(b)-sum(a)
co=0
for i in range(n):
    if a[i]>b[i]:
        co+=a[i]-b[i]
    else:
        co+=(b[i]-a[i])//2
print('Yes' if c==co else '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)


if k < 0:
    print('No')
else:
    cnt = 0
    for a, b in zip(A, B):
        if a < b:
            x, y = divmod((b-a), 2)
            cnt += x+2*y
        elif b < a:
            cnt += a-b
    if cnt <= 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()))

ret = [0] * n
for i in range(n):
    ret[i] = b[i] - a[i]
ret = sorted(ret)
minus = 0
plus = 0
for i in ret:
    if i < 0:
        minus += i
    else:
        plus += i

if abs(minus) <= plus:
    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 i in range(N):
    if A[i] <= B[i]:
        continue
    else:
        print ('No')
        exit()

print ('Yes')

Submission status: Wrong Answer

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

    asmall=0
    bsmall=0
    for a,b in zip(A,B):
        asmall+=max(0, b-a)
        bsmall+=max(0, a-b)
    print('Yes' if asmall >= bsmall*2 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()))
sa,sb = sum(A),sum(B)
if sa > sb:
    print('No')
    exit()

x = y = 0
for a,b in zip(A,B):
    if a < b:
        d,m = divmod(b-a,2)
        x += d
        y += m
    elif a > b:
        y += a-b

if x>sb-sa or y>sb-sa:
    print('No')
else:
    print('Yes' if x>=y else 'No')

Submission status: Wrong Answer

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

x = y = 0
for a,b in zip(A,B):
    if a < b:
        d,m = divmod(b-a,2)
        x += d
        y += m
    elif a > b:
        y += a-b
print('Yes' if x>=y else 'No')

Submission status: Wrong Answer

Solution code:

import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

sa = sum(a)
sb = sum(b)

al = sb-sa

if al<0:
    print('No')
    exit()

doub = 0
sing = 0

for i in range(n):
    diff = b[i]-a[i]
    if diff > 0:
        doub += diff//2
        sing += diff%2
    if diff < 0:
        sing += -diff

dnokori = al - doub
snokori = al - sing

if dnokori < 0 or snokori<0:
    print('No')
    exit()

if dnokori==0 and snokori==0:
    print('Yes')
    exit()

if dnokori==0:
    print('No')
    exit()

if snokori/dnokori == 2:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

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

    for i in range(n):
        if B[i] > A[i]:
            cnt -= (B[i] - A[i]) / 2

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


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

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

    for i in range(n):
        if B[i] > A[i]:
            cnt -= B[i] - A[i] / 2

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


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    diff = sum(B) - sum(A)
    if diff < 0:
        print("No")
        exit()

    plus_a = 0
    plus_b = 0
    for i in range(n):
        if A[i] - B[i] < 0:
            plus_a += B[i] - A[i]
        else:
            plus_b += A[i] - B[i]

    if plus_a / 2 <= diff and plus_b <= diff:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    diff = sum(B) - sum(A)
    if diff < 0:
        print("No")
        exit()

    plus_b = 0
    for i in range(n):
        if A[i] - B[i] > 0:
            plus_b += A[i] - B[i]

    if diff < plus_b:
        print("No")
    else:
        print("Yes")


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    diff_p = 0
    diff_m = 0
    for i in range(n):
        if A[i] - B[i] > 0:
            diff_p += A[i] - B[i]
        else:
            diff_m += A[i] - B[i]

    if diff_p * 2 <= abs(diff_m):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cnt_even = cnt_1 = cnt_0 = 0
for a_, b_ in zip(a, b):
    if a_ == b_:
        cnt_0 += 1
        continue
    d = b_ - a_
    if d < 0:
        cnt_1 -= d
    else:
        cnt_even += d // 2
        cnt_1 += d % 2
print("Yes") if cnt_even == cnt_1 + cnt_0 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_even = cnt_1 = cnt_0 = 0
for a_, b_ in zip(a, b):
    if a_ == b_:
        cnt_0 += 1
        continue
    d = b_ - a_
    if d < 0:
        cnt_1 += abs(d)
    else:
        cnt_even += d// 2
        cnt_1 += 1
print("Yes") if cnt_even == cnt_1 + cnt_0 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_even = cnt_1 = cnt_0 = 0
for a_, b_ in zip(a, b):
    if a_ == b_:
        cnt_0 += 1
        continue
    d = b_ - a_
    if d < 0:
        cnt_1 += abs(d)
    else:
        if d % 2:
            cnt_even += (d+1) // 2
            cnt_1 += 1
        else:
            cnt_even += d // 2
print("Yes") if cnt_even == cnt_1 + cnt_0 else print("No")

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()))
d,e=0,0
for i in range(n):
  c=a[i]-b[i]
  if c>0:
    d+=c
  else:
    e+=c
print('Yes' if 2*d<=-e else 'No')

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())))
c=a-b
d=np.sum(c[c>0])
e=-np.sum(c[c<0])
print('Yes' if 2*d<=e else 'No')

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat[i])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


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

    sb = sum(b)
    sa = sum(a)
    expected = sb - sa

    ans = 0
    for i in range(N):
        if a[i] > b[i]:
            ans += a[i] - b[i]
        else:
            ans += ((b[i] - a[i]) + 1) // 2

    print(yn[ans <= expected])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat[i])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


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

    sb = sum(b)
    sa = sum(a)
    expected = sb - sa

    ans = 0
    for i in range(N):
        if a[i] > b[i]:
            ans += a[i] - b[i]
        else:
            ans += ((b[i] - a[i]) + 1) // 2

    print(yn[ans == expected])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat[i])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N = I()
    a = LI()
    b = LI()
    diff = [0] * N
    minus = 0
    plus = 0

    for i in range(N):
        diff[i] = a[i] - b[i]
        if diff[i] < 0:
            minus += diff[i]
        else:
            plus += diff[i]

    v = plus - (abs(minus) + 1) // 2
    # print(diff, minus, plus)
    # print(v)
    if v <= 0:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat[i])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N = I()
    a = LI()
    b = LI()
    diff = [0] * N
    minus = 0
    plus = 0

    for i in range(N):
        diff[i] = a[i] - b[i]
        if diff[i] < 0:
            minus += diff[i]
        else:
            plus += diff[i]

    # print(diff, minus, plus)
    v = plus - abs(minus) // 2
    # print(v)
    if v <= 0:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat[i])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N = I()
    a = LI()
    b = LI()
    diff = [0] * N
    minus = 0
    plus = 0

    for i in range(N):
        diff[i] = a[i] - b[i]
        if diff[i] < 0:
            minus += diff[i]
        else:
            plus += diff[i]

    v = plus - abs(minus) // 2
    if minus % 2 == 0 and v <= 0:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a_li = list(map(int,input().split()))
b_li = list(map(int,input().split()))

a_li.sort()
b_li.sort()

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cnt=[0]*n
for i in range(n):
    cnt[i]=b[i]-a[i]
cnt.sort()
p=n-1
for i in range(n):
    while cnt[i]<0:
        if cnt[p]<=1:
            print("No")
            exit()
        elif cnt[p]-abs(cnt[i])*2>=2:
            cnt[p]-abs(cnt[i])*2
            cnt[i]=0
        elif cnt[p]-abs(cnt[i])*2>=0:
            cnt[p]-abs(cnt[i])*2
            cnt[i]=0
            p-=1
        else:
            x=cnt[p]//2
            cnt[i]+=x
            p-=1
print("Yes")

Submission status: Wrong Answer

Solution code:
n=input()
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a.sort()
b.sort()
sa=sum(a)
sb=sum(b)
if a==b:
    print("Yes")
elif sa>=sb:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n=input()
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a.sort()
b.sort()
sa=sum(a)
sb=sum(b)
if a==b:
    print("Yes")
elif sa>=sb:
    print("No")
else:
    while sa<sb:
        sa+=2
        sb+=1
    if sa==sb: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()))
anum=0
bnum=0
equalflag=0
for i in range(N):
    if a[i]>b[i]:   #bを嵩上げしないと
        bnum=bnum+(a[i]-b[i])
    elif a[i]<b[i]:#aを嵩上げしないと
        if (b[i]-a[i])%2==0:    #差が2nならaをn回嵩上げ
            anum=anum+(b[i]-a[i])//2
        else:                   #差が2n+1ならbを一回嵩上げしてからaをn+1回嵩上げ
            bnum=bnum+1
            anum=anum+((b[i]+1)-a[i])//2
    else:
        equalflag=1
if equalflag==1:
    if anum>=bnum:
        print("Yes")
    else:
        print("No")
else:
    if anum==bnum:
        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()))
anum=0
bnum=0
for i in range(N):
    if a[i]>b[i]:   #bを嵩上げしないと
        bnum=bnum+(a[i]-b[i])
    elif a[i]<b[i]:#aを嵩上げしないと
        if (b[i]-a[i])%2==0:    #差が2nならaをn回嵩上げ
            anum=anum+(b[i]-a[i])//2
        else:                   #差が2n+1ならbを一回嵩上げしてからaをn+1回嵩上げ
            bnum=bnum+1
            anum=anum+((b[i]+1)-a[i])//2
if anum==bnum*2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    import time
    input = sys.stdin.readline
    N = int(input())
    A = [int(x) for x in input().strip().split()]
    B = [int(x) for x in input().strip().split()]
    AB = [a - b for a, b in zip(A, B)]
    if A == B:
        print('Yes')
        exit()
    elif sum(AB) > 0:
        print('No')
        exit()
    ai = 0
    bi = 0
    while ai < N and bi < N:
        if ai != N-1 and A[ai] >= B[ai]:
            ai = min(N-1, ai+1)
            continue
        if (A[bi] - B[bi]) % 2 == 1:
            A[ai] += 2
            B[bi] += 1
            continue
        if bi != N-1 and A[bi] <= B[bi]:
            bi = min(N-1, bi+1)
            continue
        cnt = min(int((B[ai]-A[ai])/2 + .5), max(1, A[bi]-B[bi]))
        A[ai] += cnt * 2
        B[bi] += cnt
        if ai == N-1 and bi == N-1:
            AB = B[bi] - A[ai]
            A[ai] += AB * 2
            B[bi] += AB
            break
    
    if A == B:
        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=sorted(a)
b=sorted(b)
ope = 0
for i in range(n):
    if b[i] > a[i]:
        ope+=(b[i]-a[i]+1)//2

if sum(b) - sum(a) < 0:
    print('No')        
elif ope <= sum(b) - sum(a):
    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())))
for i in range(n):
    if a[i]<=b[i]:
        x=b[i]-a[i]
        a[i]=a[i]+2*x
        b[i]=b[i]+x

if a==b:
    if sum(a)<=n*(10**9):
        print('Yes')
        exit()
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())))
for i in range(n):
    if a[i]>b[i]:
        print('No')
        exit()
    elif 2*b[i]-a[i]>10**9:
        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]:
        x=b[i]-a[i]
        a[i]=a[i]+2*x
        b[i]=b[i]+x
# print(a,b)
for i in range(n):
    if a[i]>10**9 or b[i]>10**9:
        print('No')
        exit()
    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]:
        if b[i]+(b[i]-a[i])<=10**9:
            a[i]=b[i]

if a==b:
    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())))
for i in range(n):
    if a[i]<=b[i]:
        a[i]=b[i]

a=sorted(a)
b=sorted(b)
for i in range(n):
    if a[i]<=b[i]:
        a[i]=b[i]
        
if a==b:
    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())))
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=list(map(int,input().split()))
b=list(map(int,input().split()))
a.sort();b.sort()
for i in range(n):
  if a[i]>b[i]:print('No');exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 9 + 10)


def input(): return sys.stdin.readline().strip()


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

    biggerA = 0
    biggerB=0

    for i in range(N):
        if A[i] > B[i]:
            biggerA += A[i] - B[i]
        if A[i] < B[i]:
            biggerB += B[i] - A[i]

    if biggerA * 2 <= biggerB:
        print('Yes')
    else:
        print('No')


resolve()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


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

    biggerA = 0
    biggerB=0

    for i in range(N):
        if A[i] > B[i]:
            biggerA += A[i] - B[i]
        if A[i] < B[i]:
            biggerB += B[i] - A[i]

    if biggerA * 2 <= biggerB:
        print('Yes')
    else:
        print('No')


resolve()

Submission status: Wrong Answer

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

biggerA, biggerB = 0, 0

for i in range(N):
    if A[i] > B[i]:
        biggerA += A[i] - B[i]
    elif A[i] < B[i]:
        biggerB += B[i] - A[i]

if biggerA * 2 <= biggerB:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


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

    biggerA, biggerB = 0, 0

    for i in range(N):
        if A[i] > B[i]:
            biggerA += A[i] - B[i]
        elif A[i] < B[i]:
            biggerB += B[i] - A[i]

    if biggerA * 2 <= biggerB:
        print('Yes')
    else:
        print('No')


resolve()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


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

    biggerA, biggerB = 0, 0

    for i in range(N):
        if A[i] > B[i]:
            biggerA += A[i] - B[i]
        elif A[i] < B[i]:
            biggerB += B[i] - A[i]
    if biggerA <= biggerB/2:
        print('Yes')
    else:
        print('No')


resolve()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


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

    biggerA, biggerB = 0, 0

    for i in range(N):
        if A[i] > B[i]:
            biggerA += A[i] - B[i]
        elif A[i] < B[i]:
            biggerB += (B[i] - A[i]) / 2
    if biggerA > biggerB:
        print('No')
    else:
        print('Yes')


resolve()

Submission status: Wrong Answer

Solution code:
# import string
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


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

    biggerA, biggerB = 0, 0

    for i in range(N):
        if A[i] > B[i]:
            biggerA += A[i] - B[i]
        elif A[i] < B[i]:
            biggerB += (B[i] - A[i]) / 2
    if biggerA >= biggerB:
        print('No')
    else:
        print('Yes')


resolve()

Submission status: Wrong Answer

Solution code:
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    _ = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    D = [b - a for a, b in zip(A, B)]
    neg = 0
    pos = 0
    for d in D:
        if d < 0:
            neg -= d
        elif d > 1:
            pos += d

    if pos < neg * 2:
        print("No")
    else:
        print("Yes")


if __name__ == '__main__':
    main()