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:
n = int(input())

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

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

if a_sum > b_sum:
    print("No")
    exit(0)

less_a_cnt = 0
less_b_cnt = 0

for i in range(n):
    if b[i] > a[i] and (b[i] - a[i]) % 2 != 0:
        print("No")
        exit(0)

    if a[i] < b[i]:
        less_a_cnt += int((b[i] - a[i]) / 2)
    else:
        less_b_cnt += a[i] - b[i]

if less_a_cnt < less_b_cnt:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())

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

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

if a_sum > b_sum:
    print("No")
    exit(0)

less_a_sum = 0
less_b_sum = 0

for i in range(n):
    if b[i] > a[i] and (b[i] - a[i]) % 2 != 0:
        print("No")
        exit(0)

    if a[i] < b[i]:
        less_a_sum += b[i] - a[i]
    else:
        less_b_sum += a[i] - b[i]

if less_a_sum < 2 * less_b_sum:
    print("No")
    exit(0)

print("Yes")

Submission status: Wrong Answer

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

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

    ret = 'Yes'
    for i in range(N):
        if A[i]<=B[i]:
            continue
        else:
            ret = 'No'
    print(ret)

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

min_ope = sum(B) - sum(A)
exp_ope = 0
for a, b in zip(A, B):
    if a > b:
        exp_ope += a - b
    elif a < b:
        exp_ope += (b - a + 1) // 2
if min_ope >= exp_ope:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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)
for i in range(n):
    if (a[i]>b[i] and a[i]-b[i]>k) or (a[i]<b[i] and b[i]-a[i]>k*2):
        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()))
k=sum(b)-sum(a)
for i in range(n):
    if (a[i]>b[i] and a[i]-b[i]>=k*2) or (a[i]<b[i] and b[i]-a[i]>=k):
        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()))
k=sum(b)-sum(a)
for i in range(n):
    if (a[i]>b[i] and a[i]-b[i]>k*2) or (a[i]<b[i] and b[i]-a[i]>k):
        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 = 0
for i in range(n):
    if a[i] < b[i]:
        c += -((a[i]-b[i])//2)
        a[i] += -((a[i]-b[i])//2) * 2
d = 0
for i in range(n):
    if b[i] < a[i]:
        d += a[i]-b[i]
if c == d:
    ans = 1
elif c < d:
    ans = 0
elif d < c:
    if (d-c)%2 == 1:
        ans = 1
    else:
        ans = 0
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()))

a, b = 0, 0

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

# print(f"a{a} b{b}")
# print(sum(B)-sum(A))

if a+b <= sum(B)-sum(A):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

a, b = 0, 0

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

# print(f"a{a} b{b}")
# print(sum(B)-sum(A))

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

Submission status: Wrong Answer

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

a, b = 0, 0

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

# print(f"a{a} b{b}")
# print(sum(B)-sum(A))

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

a, b = 0, 0

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

# print(f"a{a} b{b}")
# print(sum(B)-sum(A))

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

Submission status: Wrong Answer

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

a, b = 0, 0

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

# print(f"a{a} b{b}")
# print(sum(B)-sum(A))

if a/2+b <= sum(B)-sum(A) and sum(B)-sum(A) >= 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()))

a, b = 0, 0

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

# print(f"a{a} b{b}")
# print(sum(B)-sum(A))

if a%2:
    aa = a//2+1
else:
    aa = a//2
if aa+b <= sum(B)-sum(A) and sum(B)-sum(A) >= 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()))

a, b = 0, 0

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

# print(f"a{a} b{b}")
# print(sum(B)-sum(A))

if a%2:
    aa = a//2+1
else:
    aa = a//2
if aa+b <= sum(B)-sum(A):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

a, b = 0, 0

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

# print(f"a{a} b{b}")
# print(sum(B)-sum(A))

if (a+1)//2+b <= 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()))

cnt = sum(B) - sum(A)
for i in range(N):
    if A[i] < B[i]:
        cnt -= (B[i]-A[i]+1)//2
        if cnt < 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()))

cnt = sum(B) - sum(A)
for i in range(N):
    if A[i] < B[i]:
        cnt -= (B[i]-A[i])//2
        if cnt < 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()))

A.sort()
B.sort()
for i in range(N):
    if A[i] > B[i]:
        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()))

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

if a_gap*2-b_gap>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()))

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

if a_gap*2>=b_gap:
    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_gap = 0
b_gap = 0
for i in range(n):
    if A[i]>B[i]:
        a_gap+=A[i]-B[i]
    if A[i]<B[i]:
        b_gap+=B[i]-A[i]

if a_gap*2>b_gap:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
N = int(sys.stdin.readline().rstrip())
A = list(map(int, sys.stdin.readline().rstrip().split()))
B = list(map(int, sys.stdin.readline().rstrip().split()))
if N == 1:
    if A[0] <= B[0]:
        print("Yes")
    else:
        print("No")
diff = [a - b for a, b in zip(A, B)]
minus = 0
plus = 0
for d in diff:
    if d < 0:
        minus += d
    else:
        plus += d
if plus * 2 + minus > 0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
N = int(sys.stdin.readline().rstrip())
A = list(map(int, sys.stdin.readline().rstrip().split()))
B = list(map(int, sys.stdin.readline().rstrip().split()))
if N == 1:
    if A[0] <= B[1]:
        print("Yes")
    else:
        print("No")
diff = [a - b for a, b in zip(A, B)]
minus = 0
plus = 0
for d in diff:
    if d < 0:
        minus += d
    else:
        plus += d
if plus * 2 + minus > 0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
N = int(sys.stdin.readline().rstrip())
A = list(map(int, sys.stdin.readline().rstrip().split()))
B = list(map(int, sys.stdin.readline().rstrip().split()))
diff = [a - b for a, b in zip(A, B)]
minus = 0
plus = 0
for d in diff:
    if d < 0:
        minus += d
    else:
        plus += d
if plus * 2 + minus > 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()))

sum1=0
sum2=0

for i,j in zip(a,b):
  if i>j:
    sum1+=2*(i-j)
  elif i<j:
    sum2+=j-i

print('Yes' if sum1<=sum2 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 i in range(n):
    dif = b[i]-a[i]
    if dif>0:x += dif 
    else:y += -dif

print('Yes' if x>=y*2 else '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 b[i]-a[i]<0:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arra=limii()
arrb=limii()

times=sum(arrb)-sum(arra)

plus=0
minus=0

for i,j in zip(arra,arrb):
    if j-i>0:
        plus+=(j-i+1)//2
    elif j-i<0:
        minus+=i-j

if times>=plus+minus:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arra=limii()
arrb=limii()

plus=0
minus=0

for i,j in zip(arra,arrb):
    if j-i>0:
        plus+=j-i
    elif j-i<0:
        minus+=j-i

if abs(minus)*2 <=plus and sum(arra)<=sum(arrb):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arra=limii()
arrb=limii()

plus=0
minus=0

for i,j in zip(arra,arrb):
    if j-i>0:
        plus+=j-i
    elif j-i<0:
        minus+=j-i

if abs(minus)*2 <plus:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arra=limii()
arrb=limii()

plus=0
minus=0

for i,j in zip(arra,arrb):
    if j-i>0:
        plus+=j-i
    elif j-i<0:
        minus+=j-i

if abs(minus)*2 <=plus:
    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()))
    # print(N, A, B)
    expected = sum(B) - sum(A)
    if expected < 0:
        print('No')
        return
    add_a, add_b = 0, 0
    for i in range(N):
        a, b = A[i], B[i]
        if a > b:
            add_b += a - b
        elif a < b:
            add_a += (b - a + 1) // 2
    if add_a + add_b <= expected:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    # print(N, A, B)
    expected = sum(B) - sum(A)
    if expected < 0:
        print('No')
        return
    add_a, add_b = 0, 0
    for i in range(N):
        a, b = A[i], B[i]
        if a > b:
            add_b += a - b
        elif a < b:
            add_a += (b - a) // 2
    if add_a + add_b <= expected:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    # print(N, A, B)
    expected = sum(B) - sum(A)
    if expected < 0:
        print('NO')
        return
    add_a, add_b = 0, 0
    for i in range(N):
        a, b = A[i], B[i]
        if a > b:
            add_b += a - b
        elif a < b:
            add_a += (b - a) // 2
    if add_a + add_b <= expected:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()

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

# 操作の回数を求める
x = b.sum() - a.sum()

# 操作回数以内に最大の差を埋められるか
ans = (b - a).max() // 2 <= x and (a - b).max() <= x

print("Yes" if ans else "No")

Submission status: Wrong Answer

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

adif,bdif=0,0
for i in range(N):
    if a[i]<b[i]:
        adif+=(b[i]-a[i])//2
    elif a[i]>b[i]:
        bdif+=a[i]-b[i]
if bdif*2<=adif:
    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()))

adif,bdif=0,0
for i in range(N):
    if a[i]<b[i]:
        adif+=b[i]-a[i]
    elif a[i]>b[i]:
        bdif+=a[i]-b[i]
if bdif*2<=adif:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
a=sorted(map(int,input().split()))
b=sorted(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()
ans = 0
for i in range(n):
    if B[i]-A[i] < 0:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
a= list(map(int,input().split()))
b= list(map(int,input().split()))
c = [a[i]-b[i] for i in range(N)]
d=sum(b)-sum(a)   #c回試行する
if d<0:
  print("No")
  exit()
  
must=0
cnt=0
for num in c:
  if num>0:
    must += abs(num)
  if num>=2:
    cnt += num//2
if must>d:
  print("No")
  exit()

#chokin = 2*must
nokori = d-must
if cnt<must:
  print("No")
else:
  print("Yes")
#print(chokin,nokori)

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(b)-sum(a)   #c回試行する
if d<0:
  print("No")
  exit()
  
must=0
cnt=0
for num in c:
  if num>0:
    must += abs(num)
  if num>=2:
    cnt +=1
if must>d:
  print("No")
  exit()

#chokin = 2*must
nokori = d-must
if cnt<must:
  print("No")
else:
  print("Yes")
#print(chokin,nokori)

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(b)-sum(a)   #c回試行する
if d<0:
  print("No")
  exit()
  
must=0
for num in c:
  if num>0:
    must += abs(num)
if must>d:
  print("No")
  exit()
#chokin = 2*must
#nokori = d-must
#print(chokin,nokori)
print("Yes")

Submission status: Wrong Answer

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

p=0
q=0
for i in range(N):
  if a[i]>b[i]:
    p += a[i]-b[i]
  elif a[i]<b[i]:
    q += b[i]-a[i]
    
#print(r)
#print(p)
#print(q) 

if r>=0 and r>=p:
  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()
#print(a)
#print(b)

if sum(a)>sum(b):
  print("No")
else:
  kachi = [a[i]-b[i] if(a[i]>b[i]) else 0 for i in range(N)]  
  make = [b[i]-a[i] if(b[i]>a[i]) else 0 for i in range(N)]  
  #print("kachi",kachi)
  #print("make",make)
  #print(sum(a))
  #print(sum(b))
  if sum(kachi)>0:
    print("No")
  else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
dat1 = list(map(int,input().split()))
dat2 = list(map(int,input().split()))
dat1.sort()
dat2.sort()
can = True
for i in range(n):
    if dat1[i] > dat2[i]:
        can = False
print("Yes" if can else "No")

Submission status: Wrong Answer

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 i == N - 1:
            a[i] += na
            b[i] += nb
            if a[i] > b[i]:
                jdg = True
            break
        if a[i] > b[i]:
            ab = a[i] - b[i]
            if nb < ab:
                na += 2 * (ab - nb)
                nb = 0
            else: nb -= ab
            sumb += ab
            b[i] += ab
        else:
            ba = b[i] - a[i]
            if na < ba:
                nb += (ba - na + 1) // 2
            else: na -= ((ba+1)//2)*2
            if nb > 0: nb -= ba%2
            else: na += 2 * (ba%2)
            suma += ((ba+1)//2)*2
            sumb += ba%2
            a[i] += ((ba+1)//2)*2
            b[i] += ba%2
    if jdg: break
print('No' if jdg else 'Yes')

Submission status: Wrong Answer

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 i == N - 1:
            a[i] += na
            b[i] += nb
            if a[i] > b[i]:
                jdg = True
            break
        if a[i] > b[i]:
            ab = a[i] - b[i]
            if nb < ab:
                na += 2 * (ab - nb)
            else: nb -= ab
            sumb += ab
            b[i] += ab
        else:
            ba = b[i] - a[i]
            if na < ba:
                nb += (ba - na + 1) // 2
            else: na -= ((ba+1)//2)*2
            suma += ((ba+1)//2)*2
            sumb += ba%2
            a[i] += ((ba+1)//2)*2
            b[i] += ba%2
    if jdg: break
print('No' if jdg else 'Yes')

Submission status: Wrong Answer

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]:
            ab = a[i] - b[i]
            b[i] = a[i]
            na += 2 * ab
            sumb += ab
        else:
            ba = b[i] - a[i]
            a[i] = b[i]            
            nb += (ba + 1) // 2
            na += 2 * (ba % 2)
            b[i] += ba%2
            a[i] = b[i]
            sumb += ba%2
            suma += ba + ba%2

    if jdg: break
print('No' if suma + na != sumb + nb else 'Yes')

Submission status: Wrong Answer

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

d=[]
for i in range(N):
    d.append(a[i]-b[i])

cnt=-sum(d)
p=0
n=0
for j in range(N):
    if d[j]>0:
        p+=d[j]
    if d[j]<0:
        n-=(d[j]+1)//2
if p<=cnt and n<=cnt:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

d=[]
for i in range(N):
    d.append(a[i]-b[i])

cnt=-sum(d)
p=0
n=0
for j in range(N):
    if d[j]>0:
        p+=d[j]
    if d[j]<0:
        n+=-d[j]/2
if p<=cnt and n<=cnt:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

d=[]
for i in range(N):
    d.append(a[i]-b[i])

cnt=-sum(d)
p=0
n=0
for j in range(N):
    if d[j]>0:
        p+=d[j]
    if d[j]<0:
        n+=-d[j]//2
if p<=cnt and n<=cnt:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

d=[]
for i in range(N):
    d.append(a[i]-b[i])

cnt=-sum(d)
n=0
for j in range(N):
    if d[j]<0:
        n+=-d[j]//2
if n<cnt:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 8)

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N = Z()
    A = ZZ()
    B = ZZ()
    if A == B:
        print('Yes')
        return
    sa, sb = sum(A), sum(B)
    if sa >= sb:
        print('No')
        return

    numDo = sb - sa
    cc = 0
    for a, b in zip(A, B):
        if a > b: cc += (a - b)
        elif a < b: cc += (b-a+1)//2
    print('Yes' if cc <= numDo else 'No')

    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 8)

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N = Z()
    A = ZZ()
    B = ZZ()
    if A == B:
        print('Yes')
        return
    sa, sb = sum(A), sum(B)
    if sa >= sb:
        print('No')
        return

    target_sum = 2 * sb - sa
    cc = 0
    for a, b in zip(A, B): cc += max(a, b)
    if cc < target_sum: print('Yes')
    elif cc == target_sum:
        print('Yes' if all([a <= b and a%2 == b%2 for a, b in zip(A, B)]) else 'No')
    else: print('No')

    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 8)

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N = Z()
    A = ZZ()
    B = ZZ()
    if A == B:
        print('Yes')
        return
    sa, sb = sum(A), sum(B)
    if sa >= sb:
        print('No')
        return

    target_sum = 2 * sb - sa
    cc = 0
    for a, b in zip(A, B): cc += max(a, b)
    print('Yes' if cc < target_sum else 'No')

    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 8)

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N = Z()
    A = ZZ()
    B = ZZ()
    if A == B:
        print('Yes')
        return
    sa, sb = sum(A), sum(B)
    if sa >= sb:
        print('No')
        return

    target_sum = 2 * sb - sa
    cc = 0
    for a, b in zip(A, B): cc += max(a, b)
    print('Yes' if cc <= target_sum else 'No')

    return

if __name__ == '__main__':
    main()