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.sort()
b.sort()


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



#sum(a)+2*k=sum(b)+k
#k=(sum(a)-sum(b))

k=suma-sumb
#
#1 1 1 6
#2 2 2 3


cnta=0
cntb=0
for i in range(n):
    if a[i]>b[i]:
        cntb+=b[i]-a[i]
    elif a[i]<b[i]:
        cnta+=((-1)*(a[i]-b[i])//2)

if cnta<=k and cntb<=k:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())

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

a.sort()
b.sort()


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



#sum(a)+2*k=sum(b)+k
#k=(sum(a)-sum(b))

k=suma-sumb
#
#1 1 1 6
#2 2 2 3

if k<0:
    print("No")
    exit()
cnt=0
for i in range(n):
    if a[i]>b[i]:
        cnt+=b[i]-a[i]
    elif a[i]<b[i]:
        cnt+=((-1)*(a[i]-b[i])//2)

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

a.sort()
b.sort()


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



#sum(a)+2*k=sum(b)+k
#k=(sum(a)-sum(b))

k=suma-sumb
#
#1 1 1 6
#2 2 2 3

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

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

a.sort()
b.sort()


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



#sum(a)+2*k=sum(b)+k
#k=(sum(a)-sum(b))

k=suma-sumb
#
#1 1 1 6
#2 2 2 3

cnt=0
for i in range(n):
    if a[i]>b[i]:
        cnt+=b[i]-a[i]
    elif a[i]<b[i]:
        cnt+=(-1)*((a[i]-b[i])//2)

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

a.sort()
b.sort()

if a==b:
    print("Yes")
    exit()

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

if suma>=sumb:
    print("No")
    exit()

#sum(a)+2*k=sum(b)+k
#k=(sum(a)-sum(b))

k=suma-sumb
#
#1 1 1 6
#2 2 2 3

cnt=0
for i in range(n):
    if a[i]>b[i]:
        cnt+=b[i]-a[i]
    elif a[i]<b[i]:
        cnt+=(-1)*((a[i]-b[i])//2)

if cnt>=k:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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


    bamari = 0
    for i in range(N):
        if A[i] == B[i]:
            continue
        elif A[i] > B[i]:
            bamari -= A[i] - B[i]
        else:
            if B[i] - A[i] == 1:
                continue
            bamari += -(-(B[i] - A[i])) // 2
            bamari -= (B[i] - A[i]) % 2

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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

    if sum(A) > sum(B):
        print("No")
        return

    bamari = 0
    for i in range(N):
        if A[i] == B[i]:
            continue
        elif A[i] > B[i]:
            bamari -= A[i] - B[i]
        else:
            bamari += -(-(B[i] - A[i])) // 2
            bamari -= (B[i] - A[i]) % 2

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
(n,),aa,bb = [list(map(int, s.split())) for s in open(0)]

up = down = 0

for i in range(n):
    a = aa[i]
    b = bb[i]
    if a > b:
        down += a-b
    if b > a:
        up += b-a

if down * 2 <= up:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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


    bamari = 0
    for i in range(N):
        if A[i] == B[i]:
            continue
        elif A[i] > B[i]:
            bamari -= A[i] - B[i]
        else:
            bamari += -(-(B[i] - A[i])) // 2
            bamari -= (B[i] - A[i]) % 2

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



    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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

    acnt = 0
    bcnt = 0

    for i in range(N):
        if A[i] == B[i]:
            continue
        elif A[i] > B[i]:
            bcnt += A[i] - B[i]
        else:
            acnt += -(-(B[i] - A[i])) // 2
            bcnt += (B[i] - A[i]) % 2

    sa = sum(A)
    sb = sum(B)
    cnt = abs(sa - sb)
    if acnt < bcnt:
        print("No")
    else:
        if acnt + bcnt == cnt:
            print("Yes")
        else:
            print("No")


    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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

    acnt = 0
    bcnt = 0

    for i in range(N):
        if A[i] == B[i]:
            continue
        elif A[i] > B[i]:
            bcnt += A[i] - B[i]
        else:
            acnt += -(-(B[i] - A[i])) // 2
            bcnt += (B[i] - A[i]) % 2

    if acnt < bcnt:
        print("No")
    else:
        print("Yes")


    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


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

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

    if bb == ba:
        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()))

result = False

big_a = sum([ai - bi for ai, bi in zip(a,b) if ai > bi])
big_b = sum([(bi - ai) / 2 for ai, bi in zip(a,b) if bi > ai])
sum_diff = sum(b) - sum(a)

if big_a <= sum_diff and big_b <= sum_diff:
  result = True

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

Submission status: Wrong Answer

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

result = False

big_a = sum([ai - bi for ai, bi in zip(a,b) if ai > bi])
big_b = sum([(bi - ai) / 2 for ai, bi in zip(a,b) if bi > ai])
sum_diff = sum(b) - sum(a)

if big_a <= big_b and sum_diff >= 0:
  result = True

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

Submission status: Wrong Answer

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

result = False

big_A = sum([ai - bi for ai, bi in zip(a,b) if ai > bi])
big_B = sum([(bi - ai) / 2 for ai, bi in zip(a,b) if bi > ai])

if big_A <= big_B:
  result = True

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

Submission status: Wrong Answer

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

result = False

big_A = sum([ai - bi for ai, bi in zip(a,b) if ai > bi])
big_B = sum([(bi - ai) / 2 for ai, bi in zip(a,b) if bi > ai])

if big_A < big_B:
  result = True

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

Submission status: Wrong Answer

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

ans = False
rule1 = sum(a) <= sum(b)
rule2 = sum([ai - bi for ai, bi in zip(a,b) if ai > bi]) <= sum(b) - sum(a)
rule3 = sum([(bi - ai) for ai, bi in zip(a,b) if bi > ai]) <= 2 * (sum(b) - sum(a))
if rule1 and rule2 and rule3:
  ans = True

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

Submission status: Wrong Answer

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

ans = False
rule1 = sum(a) <= sum(b)
rule2 = sum([ai - bi for ai, bi in zip(a,b) if ai > bi]) <= sum(b) - sum(a)
rule3 = sum([(bi - ai) *2 for ai, bi in zip(a,b) if bi > ai]) <= sum(b) - sum(a)
if rule1 and rule2 and rule3:
  ans = True

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

Submission status: Wrong Answer

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

ans = False
rule1 = sum(a) <= sum(b)
rule2 = sum([2 * (ai - bi) for ai, bi in zip(a,b) if ai > bi]) <= sum(b) - sum(a)
rule3 = sum([bi - ai for ai, bi in zip(a,b) if bi > ai]) <= sum(b) - sum(a)
if rule1 and rule2 and rule3:
  ans = True

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

Submission status: Wrong Answer

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

ans = False
rule1 = sum(a) <= sum(b)
rule2 = sum([ai - bi for ai, bi in zip(a,b) if ai > bi]) <= sum(b) - sum(a)
rule3 = sum([bi - ai for ai, bi in zip(a,b) if bi > ai]) <= sum(b) - sum(a)
if rule1 and rule2 and rule3:
  ans = True

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

Submission status: Wrong Answer

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

ans = False
rule1 = sum(a) <= sum(b)
rule2 = sum([ai - bi for ai, bi in zip(a,b) if ai > bi]) <= sum(b) - sum(a)
if rule1 and rule2:
  ans = True

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

Submission status: Wrong Answer

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

ans = False
rule1 = sum(a) <= sum(b)
rule2 = sum([bi - ai for ai, bi in zip(a,b) if ai < bi]) <= sum(b) - sum(a)
if rule1 and rule2:
  ans = True

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

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)
cb = sum([a-b for b,a in zip(B,A) if b<a])
ca = sum([(b-a+1)//2 for b,a in zip(B,A) if b>a])
if ca+cb <= 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()))
print('Yes' if sum(b)-sum(a)==n else 'No')

Submission status: Wrong Answer

Solution code:
N = int(input())

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

if sum(As) > sum(Bs):
  print('No')
  exit()
  
dif = sum(Bs) - sum(As)
A = 0
for i in range(N):
  if As[i] > Bs[i]:
    A += As[i] - Bs[i]
    
if A > dif:
  print('No')
else:
  print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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

for ai,bi in zip(a,b):
    if ai<=bi:
        continue
    else:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
import sys

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
B = list(map(int, sys.stdin.readline().split()))
# print(A)
# print(B)

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

need_an = 0
need_bn = 0
for i in range(N):
    if A[i] > B[i]:
        need_bn += A[i] - B[i]
    elif A[i] < B[i]:
        tmp = B[i] - A[i]
        need_an += tmp // 2

# print(need_n, need_an, need_bn)
if sum_a <= sum_b and need_n >= need_an + need_bn:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def main():
    import sys

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

    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    s = 0
    sm = 0
    for x, y in zip(a,b):
        tmp = y-x
        sm += tmp
        if tmp > 0:
            tmp //= 2
        s += tmp
    if s >= sm and sm >= 0:
        print('Yes')
    else:
        print('No')

    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys

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

    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    s = 0
    sm = 0
    for x, y in zip(a,b):
        tmp = y-x
        sm += tmp
        if tmp > 0:
            tmp //= 2
        s += tmp
    if s >= sm:
        print('Yes')
    else:
        print('No')

    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
B = list(map(int, sys.stdin.readline().split()))
# print(A)
# print(B)

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

need_an = 0
need_bn = 0
for i in range(N):
    if A[i] > B[i]:
        need_bn += A[i] - B[i]
    elif A[i] < B[i]:
        tmp = B[i] - A[i]
        need_an += tmp // 2
        if tmp % 2:
            need_bn += 1

# print(need_n, need_an, need_bn)
if sum_a <= sum_b and need_an >= need_bn:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def main():
    import sys

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

    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    s = 0
    sm = 0
    for x, y in zip(a,b):
        tmp = x-y
        sm += tmp
        if tmp == -1:
            tmp = 0
        if tmp > 0:
            tmp *= 2
        s += tmp
    if s > 0 or sm > 0:
        print('No')
    else:
        print('Yes')

    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
B = list(map(int, sys.stdin.readline().split()))
# print(A)
# print(B)

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

need_an = 0
need_bn = 0
for i in range(N):
    if A[i] > B[i]:
        need_bn += A[i] - B[i]
    elif A[i] < B[i]:
        tmp = B[i] - A[i]
        need_an += tmp // 2
        if tmp % 2:
            need_bn += 1

# print(need_n, need_an, need_bn)
if need_n >= need_an + need_bn:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
B = list(map(int, sys.stdin.readline().split()))

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

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

# print(need_n, need_an, need_bn)
if need_n >= need_an + need_bn:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
B = list(map(int, sys.stdin.readline().split()))

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

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

# print(need_n, need_an, need_bn)
if need_n == need_an + need_bn:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
B = list(map(int, sys.stdin.readline().split()))

if A == B:
    print("Yes")
    sys.exit()

sum_a = sum(A)
sum_b = sum(B)
# print(sum_a, sum_b)
# print(sorted(A))
# print(sorted(B))
if sum_a <= sum_b :
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def main():
    import sys

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

    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    s = 0
    for x, y in zip(a,b):
        tmp = x-y
        if tmp == -1:
            tmp = 0
        if tmp > 0:
            tmp *= 2
        s += tmp
    if s > 0:
        print('No')
    else:
        print('Yes')

    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys

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

    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    s = 0
    for x, y in zip(a,b):
        tmp = x-y
        if tmp > 0:
            tmp *= 2
        s += tmp
    if s > 0:
        print('No')
    else:
        print('Yes')

    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    A = [int(i) for i in input().strip().split()]
    B = [int(i) for i in input().strip().split()]

    _diff_A, _diff_B = 0, 0
    m = sum(B) - sum(A)  # 操作回数の上限
    for i in range(n):
        if A[i] > B[i]:
            _diff_A += A[i] - B[i]
        elif B[i] > A[i]:
            _diff_B += B[i] - A[i]

    if _diff_B >= _diff_A * 2 and _diff_A <= m and _diff_B // 2 <= m:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    A = [int(i) for i in input().strip().split()]
    B = [int(i) for i in input().strip().split()]

    _diff_A, _diff_B = 0, 0

    for i in range(n):
        if A[i] > B[i]:
            _diff_A += A[i] - B[i]
        elif B[i] > A[i]:
            _diff_B += (B[i] - A[i] + 1) // 2

    if _diff_B >= _diff_A:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    A = [int(i) for i in input().strip().split()]
    B = [int(i) for i in input().strip().split()]

    _diff_A, _diff_B = 0, 0

    for i in range(n):
        if A[i] > B[i]:
            _diff_A += A[i] - B[i]
        elif B[i] > A[i]:
            _diff_B += B[i] - A[i]

    if _diff_B > _diff_A * 2:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    A = [int(i) for i in input().strip().split()]
    B = [int(i) for i in input().strip().split()]

    _diff_A, _diff_B = 0, 0

    for i in range(n):
        if A[i] > B[i]:
            _diff_A += A[i] - B[i]
        elif B[i] > A[i]:
            _diff_B += B[i] - A[i]

    if _diff_B >= _diff_A * 2:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
s=0
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
a=sum(A)
b=sum(B)
k=0
if a>b:
  print("No")
  sys.exit()
for i in range(N):
  if A[i]-B[i]>0:
    s+=A[i]-B[i]
    k+=1
  elif abs(A[i]-B[i])%2==1:
    k+=1
if b-a<s:
  print("No")
  sys.exit()
if k==N:
  print("No")
  sys.exit()
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
s=0
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
a=sum(A)
b=sum(B)
if a>b:
  print("No")
  sys.exit()
for i in range(N):
  if A[i]-B[i]>0:
    s+=A[i]-B[i]
if b-a<s:
  print("No")
  sys.exit()
else:
  print("Yes")

Submission status: Wrong Answer

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

max_count = sum(b) - sum(a)
count = 0
for i in range(n):
    if a[i] > b[i]:
        count += (a[i] - b[i])
    elif a[i] < b[i]:
        if (b[i] - a[i]) % 2 == 0:
            count += (b[i] - a[i]) // 2
        else:
            count += (b[i] - a[i]) // 2 + 1
    else: continue

if count <= max_count:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

max_count = sum(b) - sum(a)
count = 0
for i in range(n):
    if a[i] > b[i]:
        count += (a[i] - b[i])
    elif a[i] < b[i]:
        if (b[i] - a[i]) % 2 == 0:
            count += (b[i] - a[i]) // 2
        else:
            count += (b[i] - a[i]) // 2 + 1
    else: continue

if count <= max_count:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
print("No")

Submission status: Wrong Answer

Solution code:
n,*a=map(int,open(0).read().split())
print("Yes" if sum(j-i if j-i>0 else 2*(j-i)for i,j in zip(a[:n],a[n:]))>=0 else "No")

Submission status: Wrong Answer

Solution code:
n,*a=map(int,open(0).read().split())
u=d=z=0
for i,j in zip(a[:n],a[n:]):
    if j-i>0:u+=j-i
    elif j-i==0:z+=1
    else:d+=j-i
print("Yes" if u+2*d>=0 else "No")

Submission status: Wrong Answer

Solution code:
n,*a=map(int,open(0).read().split())
u=d=z=0
for i,j in zip(a[:n],a[n:]):
    if j-i>0:u+=j-i
    elif j-i==0:z+=1
    else:d+=j-i
print("Yes" if u+2*d>0 else "No")

Submission status: Wrong Answer

Solution code:
n,*a=map(int,open(0).read().split())
u=d=z=0
for i,j in zip(a[:n],a[n:]):
    if j-i>0:u+=j-i
    elif j-i==0:z+=1
    else:d+=j-i
print("Yes" if (z==0 and u+2*d==0)or (z>0 and u+d>=0) else "No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
cou = 0
for j,k in zip(a,b):
  if j<k:
    cou += (k-j)//2
  elif j>k:
    cou -= (j-k)
if cou>0:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

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

    # 操作回数
    n = sum(b) - sum(a)

    if sum([max(b[i] - a[i], 0) for i in range(N)]) <= 2 * n and sum([max(a[i] - b[i], 0) for i in range(N)]) <= n:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

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

    if sum([max(b[i] - a[i], 0) for i in range(N)]) > sum([max(a[i] - b[i], 0) for i in range(N)]) * 2:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

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

    if sum([max(b[i] - a[i], 0) for i in range(N)]) >= sum([max(a[i] - b[i], 0) for i in range(N)]) * 2:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
def check():
  N = int(input())
  A = list(map(int, input().split()))
  B = list(map(int, input().split()))
  diff = sum(B)-sum(A)
  if diff < 0:
    return 'No'
  cnt = 0
  for i in range(N):
    cnt += max(B[i]-A[i],0)
  if diff*2 < cnt:
    return 'No'
  return 'Yes'
print(check())

Submission status: Wrong Answer

Solution code:
import sys


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


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    if A == B:
        print("Yes")
        return

    A.sort()
    B.sort()

    for i in range(N):
        if A[i] > B[i]:
            print("No")
            return
    if sum(A) >= sum(B):
        print("No")
        return

    print("Yes")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline


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

    n_2 = 0
    n_1 = 0
    for a, b in zip(A, B):
        if a > b:
            n_1 += (a - b)
        elif a < b:
            n_2 += (b - a) // 2

    diff = sum(B) - sum(A)
    if diff < 0:
        ans = "No"
    elif n_1 <= diff and n_2 <= diff:
        ans = "Yes"
    else:
        ans = "No"
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline


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

    n_2 = 0
    n_1 = 0
    for a, b in zip(A, B):
        if a > b:
            n_1 += (a - b)
        elif a < b:
            n_2 += (b - a) // 2

    diff = sum(B) - sum(A)
    if n_1 <= diff and n_2 <= diff:
        ans = "Yes"
    else:
        ans = "No"
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

    while k > 0 and now < N:
        while now < N and A[now] == B[now]:
            now += 1
        
        if now < N:
            l = B[now] - A[now]
            if k >= l:
                k -= l
                A[now] += 2*l
                B[now] += l
                now += 1
            elif k >= -l:
                k -= l
                A[-1] += 2*l
                B[now] += l
                now += 1
            else:
                k = 0
                now = -1
                break
    
    if now == N:
        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()))
    A.sort()
    B = list(map(int, input().split()))
    B.sort()
    sum_a = sum(A)
    sum_b = sum(B)
    k = sum_b - sum_a

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

    while k > 0 and now < N:
        while now < N and  A[now] == B[now]:
            now += 1
        
        if now < N:
            l = B[now] - A[now]
            if k >= l:
                k -= l
                A[now] += 2*l
                B[now] += l
            else:
                k = 0
                now = -1
                break

            if A[now] == B[now]:
                now += 1
    
    if now == N:
        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()))
    A.sort()
    B = list(map(int, input().split()))
    B.sort()
    sum_a = sum(A)
    sum_b = sum(B)
    k = sum_b - sum_a

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

    while k > 0 and now < N:
        while now < N and  A[now] == B[now]:
            now += 1
        
        if now < N:
            l = A[now] - B[now]
            if k >= l:
                k -= l
                A[now] += 2*l
                B[now] += l
            else:
                k = 0
                now = -1
                break

            if A[now] == B[now]:
                now += 1
    
    if now == N:
        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()))
if all(a[i]==b[i] for i in range(n)):
    print("Yes")
elif sum(a)==sum(b):
    print("No")
elif sum(b)<sum(a):
    print("No")
else:
    tmp=0
    for i in range(n):
        if a[i]-b[i]>0:
            tmp-=2*(a[i]-b[i])
        if a[i]-b[i]<0:
            tmp+=b[i]-a[i]
    if tmp>=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()))
if all(a[i]==b[i] for i in range(n)):
    print("Yes")
elif sum(a)==sum(b):
    print("No")
elif sum(b)<sum(a):
    print("No")
else:
    if (sum(b)-sum(a))%2==0:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
alist=list(map(int,input().split()))
blist=list(map(int,input().split()))

difflist=[]
for i in range(n):
	difflist.append(blist[i]-alist[i])

needcount=sum(difflist)
if needcount < 0:
	print("No")
	sys.exit()
elif needcount == 0:
	for diff in difflist:
		if diff != 0:
			print("No")
			sys.exit()
	print("Yes")
	sys.exit()

posineed=0
neganeed=0

for diff in difflist:
	if diff < 0:
		neganeed += -diff
	elif diff > 0:
		posineed += diff // 2
	if diff % 2 == 1:
		neganeed += 1

if posineed == neganeed:
	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()))
sum_a= sum(a)
sum_b = sum(b)
if sum_a>sum_b:
  print("No")
  exit()
#num回操作を行うことができる.  
num = sum_b-sum_a
sa_a = 0
sa_b = 0
cou = 0
for j,k in zip(a,b):
  if j>k:
    sa_b += j-k
    cou += 1
  elif k>j:
    sa_a += k-j
#print(sa_a,cou,sa_b)
if sa_a-(num-cou)-2*sa_b==0:
  print("Yes")
else:
  print("No")