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 = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ca = 0
cb = 0
for i, j in zip(a, b):
    if i < j:
        ca += j-i
    else:
        cb += i-j
n = sum(b)-sum(a)
print("Yes" if n >= cb and n >= ca/2 else "No")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ca = 0
cb = 0
for i, j in zip(a, b):
    if i < j:
        ca += j-i
    else:
        cb += i-j
print("Yes" if ca-cb == sum(b)-sum(a) and ca/2 >= cb else "No")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ca = 0
cb = 0
for i, j in zip(a, b):
    if i < j:
        ca += j-i
    else:
        cb += i-j
print("Yes" if ca/2 >= cb else "No")

Submission status: Wrong Answer

Solution code:
def examB():
    N = I()
    A = LI(); B = LI()
    dif = sum(B) -sum(A)
    cur = 0; cur2 = 0
    for i in range(N):
        if A[i]>=B[i]:
            cur += A[i]-B[i]
        else:
            cur2 +=1
    if dif>=cur and dif>=cur2:
        ans = "Yes"
    else:
        ans = "No"
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

Submission status: Wrong Answer

Solution code:
def examB():
    N = I()
    A = LI(); B = LI()
    dif = sum(B) -sum(A)
    cur = 0
    for i in range(N):
        cur += max(0,A[i]-B[i])
    if dif>=cur:
        ans = "Yes"
    else:
        ans = "No"
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

Submission status: Wrong Answer

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

pm = 0
for i in range(N) :
    if a[i] >= b[i] :
        pm += 2 * (a[i] - b[i])
    else :
        if a[i] % 2 != b[i] % 2 :
            pm += 2
        pm -= b[i] - a[i]
        
if pm > 0 :
    print('No')
else :
    print('Yes')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    n = 0
    for a, b in zip(A, B):
        if a > b:
            n += a - b
    if n + sum(A) <= sum(B):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np


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

    C = np.zeros([2, N], dtype=np.int64)
    C[0, :] = A
    C[1, :] = B
    d = np.diff(C, axis=0)
    print(d)
    cnt1 = np.sum(d)
    cnt2 = np.sum(d)
    for i in range(len(d[0, :])):
        if d[0, i] > 0:
            cnt1 -= d[0, i] // 2
        if d[0, i] < 0:
            cnt2 -= -d[0, i]

    print('Yes' if cnt1 >= 0 else 'No')


main()

Submission status: Wrong Answer

Solution code:
import numpy as np


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

    C = np.zeros([2, N], dtype=np.int64)
    C[0, :] = A
    C[1, :] = B
    d = np.diff(C, axis=0)
    print(d)
    cnt1 = np.sum(d)
    cnt2 = np.sum(d)
    for i in range(len(d[0, :])):
        if d[0, i] > 0:
            cnt1 -= int(d[0, i] / 2)
        if d[0, i] < 0:
            cnt2 -= -d[0, i]

    print('Yes' if cnt1 >= 0 else 'No')


main()

Submission status: Wrong Answer

Solution code:
import numpy as np


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

    C = np.zeros([2, N], dtype=np.int64)
    C[0, :] = A
    C[1, :] = B
    d = np.diff(C, axis=0)
    cnt1 = np.sum(d)
    cnt2 = np.sum(d)
    for i in range(len(d[0, :])):
        if d[0, i] > 0:
            cnt1 -= d[0, i] / 2
        if d[0, i] < 0:
            cnt2 -= -d[0, i]

    print('Yes' if min(cnt1, cnt2) >= 0 else 'No')


main()

Submission status: Wrong Answer

Solution code:
import numpy as np


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

    C = np.zeros([2, N], dtype=np.int64)
    C[0, :] = A
    C[1, :] = B
    d = np.diff(C, axis=0)
    cnt1 = np.sum(d)
    cnt2 = np.sum(d)
    for i in range(len(d[0, :])):
        if d[0, i] > 0:
            cnt1 -= d[0, i] / 2
        if d[0, i] < 0:
            cnt2 += d[0, i]

    print('Yes' if max(cnt1, cnt2) >= 0 else 'No')


main()

Submission status: Wrong Answer

Solution code:
import numpy as np


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

    C = np.zeros([2, N], dtype=np.int32)
    C[0, :] = A
    C[1, :] = B
    d = np.diff(C, axis=0)
    cnt = np.sum(d)
    for i in range(len(d[0, :])):
        if d[0, i] > 0:
            cnt -= d[0, i] / 2

    print('Yes' if cnt >= 0 else 'No')


main()

Submission status: Wrong Answer

Solution code:
import numpy as np


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

    if A == B:
        print('Yes')
    else:
        C = np.zeros([2, N], dtype=np.int32)
        C[0, :] = A
        C[1, :] = B
        d = np.diff(C, axis=0)
        cnt = np.sum(d)
        for i in range(len(d[0, :])):
            if d[0, i] > 0:
                cnt -= d[0, i] / 2

        print('Yes' if cnt >= 0 else 'No')


main()

Submission status: Wrong Answer

Solution code:
import numpy as np


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

    if A == B:
        print('Yes')
    else:
        C = np.zeros([2, N], dtype=np.int32)
        C[0, :] = A
        C[1, :] = B
        d = np.diff(C, axis=0)
        cnt = np.sum(d)
        for i in range(len(d[0, :])):
            if d[0, i] > 0:
                cnt -= d[0, i] / 2

        print('Yes' if cnt < 0 else 'No')


main()

Submission status: Wrong Answer

Solution code:
import numpy as np


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

    if A == B:
        print('Yes')
    else:
        C = np.zeros([2, N], dtype=np.int32)
        C[0, :] = A
        C[1, :] = B
        d = np.diff(C, axis=0)
        cnt = np.sum(d)
        for i in range(len(d[0, :])):
            if d[0, i] < 0:
                cnt -= d[0, i] / 2

        print('Yes' if cnt < 0 else 'No')


main()

Submission status: Wrong Answer

Solution code:
import numpy as np


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

    if A == B:
        print('Yes')
    else:
        C = np.zeros([2, N], dtype=np.int32)
        C[0, :] = A
        C[1, :] = B
        d = np.diff(C, axis=0)
        cnt = np.sum(d)
        for i in range(len(d[0, :])):
            if d[0, i] < 0:
                cnt -= -d[0, i]
            else:
                cnt -= d[0, i] / 2

        print('Yes' if cnt < 0 else 'No')


main()

Submission status: Wrong Answer

Solution code:
import numpy as np


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

    if A == B:
        print('Yes')
    else:
        C = np.zeros([2, N], dtype=np.int32)
        C[0, :] = A
        C[1, :] = B
        d = np.diff(C, axis=0)
        e = d[d > 0]
        f = d[d < 0]
        if np.sum(e) < -2 * np.sum(f):
            print('No')
        else:
            for i in range(len(f)):
                for j in range(len(e)):
                    if e[j] >= -2 * f[i]:
                        e[j] -= -2 * f[i]
                        f[i] += -f[i]
                        break
                    elif e[j] >= 2:
                        e[j] -= 2
                        f[i] += 1
                        break

            if np.all(e % 2 != 0):
                print('No')
            else:
                print('Yes')


main()

Submission status: Wrong Answer

Solution code:
import numpy as np


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

    if A == B:
        print('Yes')
    else:
        C = np.zeros([2, N], dtype=np.int32)
        C[0, :] = A
        C[1, :] = B
        d = np.diff(C, axis=0)
        e = d[d >= 0]
        f = d[d < 0]
        if np.sum(e) < -2 * np.sum(f):
            print('No')
        else:
            for i in range(len(f)):
                for j in range(len(e)):
                    if e[j] >= -2 * f[i]:
                        e[j] -= -2 * f[i]
                        f[i] += -f[i]
                    elif e[j] >= 2:
                        e[j] -= 2
                        f[i] += 1

            if np.all(e % 2 != 0):
                print('No')
            else:
                print('Yes')


main()

Submission status: Wrong Answer

Solution code:
import numpy as np


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

    if A == B:
        print('Yes')
    else:
        C = np.zeros([2, N], dtype=np.int32)
        C[0, :] = A
        C[1, :] = B
        d = np.diff(C, axis=0)
        a = np.sum(d[d > 0])
        b = np.sum(d[d < 0])
        if a >= -2 * b:
            print('Yes')
        elif (-2 * b - a) % 2 == 0:
            print('Yes')
        else:
            print('No')


main()

Submission status: Wrong Answer

Solution code:
import numpy as np


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

    if A == B:
        print('Yes')
    else:
        C = np.zeros([2, N], dtype=np.int32)
        C[0, :] = A
        C[1, :] = B
        d = np.diff(C, axis=0)
        a = np.sum(d[d > 0])
        b = np.sum(d[d < 0])
        if a >= -2 * b:
            print('Yes')
        else:
            print('No')


main()

Submission status: Wrong Answer

Solution code:
def main():
    _ = int(input())
    nega = 0
    posi = 0
    nega_max = 0
    posi_max = 0
    diff_odd = False
    A = (int(i) for i in input().split())
    B = (int(i) for i in input().split())
    for a, b in zip(A, B):
        diff = a-b
        if diff < 0:
            nega += abs(diff)
            nega_max = max(nega_max, abs(diff))
            if abs(diff) & 1:
                diff_odd = True
        else:
            posi += diff
            posi_max = max(posi_max, diff)
    if 2*posi < nega:
        print("Yes")
    elif 2*posi == nega and not(diff_odd):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    _ = int(input())
    nega = 0
    posi = 0
    nega_max = 0
    posi_max = 0
    diff_odd = False
    A = (int(i) for i in input().split())
    B = (int(i) for i in input().split())
    for a, b in zip(A, B):
        diff = a-b
        if diff < 0:
            nega += abs(diff)
            nega_max = max(nega_max, abs(diff))
            if diff & 1:
                diff_odd = True
        else:
            posi += diff
            posi_max = max(posi_max, diff)
    if 2*posi < nega:
        print("Yes")
    elif 2*posi == nega and not(diff_odd):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    _ = int(input())
    nega = 0
    posi = 0
    nega_max = 0
    posi_max = 0
    A = (int(i) for i in input().split())
    B = (int(i) for i in input().split())
    for a, b in zip(A, B):
        diff = a-b
        if diff < 0:
            nega += abs(diff)
            nega_max = max(nega_max, abs(diff))
        else:
            posi += diff
            posi_max = max(posi_max, diff)
    if 2*posi <= nega and 2*posi_max <= nega_max:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    _ = int(input())
    nega = 0
    posi = 0
    A = (int(i) for i in input().split())
    B = (int(i) for i in input().split())
    for a, b in zip(A, B):
        diff = a-b
        if diff < 0:
            nega += abs(diff)
        else:
            posi += diff
    if (posi & 1 and 2*posi <= nega) or (posi % 2 == 0 and 2*posi < nega):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    _ = int(input())
    nega = 0
    posi = 0
    A = (int(i) for i in input().split())
    B = (int(i) for i in input().split())
    for a, b in zip(A, B):
        diff = a-b
        if diff < 0:
            nega += abs(diff)
        else:
            posi += diff
    if 2*posi <= nega:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
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
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    A=LI()
    B=LI()
    cnt1=0
    cnt2=0
    for a,b in zip(A,B):
        if a>b:
            cnt1 += a-b
        else:
            cnt2 += b-a
    if cnt1*2<=cnt2:
        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()))

times = sum(b) - sum(a)
if times < 0:
    print("No")
    exit()

times_b = 0
for i in range(n):
    if b[i] < a[i]:
        times_b += a[i] - b[i]

if times < times_b:
    print("No")
elif times > times_b:
    print("Yes")
else:
    print("Yes")

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(a)<=sum(b) else 'No')

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]

def main():
    n=inp()
    a=inpl()
    b=inpl()
    if sum(a)>sum(b):
        print("No")
        return
    dif = sum(b) - sum(a)
    for i in range(n):
        if a[i]>b[i]:
            dif -= (a[i]-b[i])
    if dif < 0:
        print("No")
        return
    print("Yes")



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left
N = int(input())
Alist = sorted(list(map(int, input().split())))
Blist = sorted(list(map(int, input().split())))
if (sum(Alist) - sum(Blist)) % 2 != 0 and sum(Alist) <= sum(Blist):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left
N = int(input())
Alist = sorted(list(map(int, input().split())))
Blist = sorted(list(map(int, input().split())))
if (sum(Alist) - sum(Blist)) % 2 != 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
Alist = np.array(sorted(list(map(int, input().split()))))
Blist = np.array(sorted(list(map(int, input().split()))))

sbn = Blist - Alist
print("Yes" if np.all(sbn >= 0) else "No")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
 
##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)
 
##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力
 
# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと
 
##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順
 
# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    A = inputList()
    B = inputList()
    
    sa = []
    for i in range(N):
        tmp = B[i] - A[i]
        if tmp < 0:
            sa.append(tmp*2)
        elif tmp > 0:
            sa.append(tmp)
        else:
            sa.append(0)
            
    ans = 0
    for i in sa:
        ans += i
        
    if ans >= 0:
        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()))
need=sum(b)-sum(a)
import math
x=0
a.sort()
b.sort()
for i in range(n):
	if a[i]>b[i]:
		x+=a[i]-b[i]
	else:
		x+=math.ceil((b[i]-a[i])/2)
if x<=need:
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
need=sum(b)-sum(a)
import math
x=0
for i in range(n):
	if a[i]>b[i]:
		x+=a[i]-b[i]
	else:
		x+=math.ceil((b[i]-a[i])/2)
if x<=need:
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
 
##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)
 
##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力
 
# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと
 
##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順
 
# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    A = inputList()
    B = inputList()
    
    sa = []
    for i in range(N):
        tmp = B[i] - A[i]
        if tmp < 0:
            sa.append(tmp*2)
        elif tmp > 0:
            sa.append(tmp)
        else:
            sa.append(0)
            
    ans = 0
    for i in sa:
        ans += i
        
    if ans > 0:
        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_b = b_a = 0
for a, b in zip(A, B):
    a_b += max(0, a-b) + max(0, (b-a)%2)
    b_a += max(0, (b-a)//2)
t = max(a_b, b_a)
#print(t)
if sum(B)-sum(A) >= t:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l1=LI()
  l2=LI()

  l1.sort()
  l2.sort()

  m=0
  for i,x in enumerate(l1):
    y=l2[i]
    if x>y:
      if x<=y+m:
        m-=(x-y)
      else:
        return 'No'
    else:
      m+=(y-x)//2
  return 'Yes'

# main()
print(main())

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l1=LI()
  l2=LI()

  l1.sort()
  l2.sort()

  for i,x in enumerate(l1):
    y=l2[i]
    if x>y:
      return 'No'
  return 'Yes'

# main()
print(main())

Submission status: Wrong Answer

Solution code:
n = int(input())
an = [int(i) for i in input().split()]
bn = [int(i) for i in input().split()]
x,y = 0,0
for a,b in zip(an,bn):
  if a >= b:
    x += a-b
  else:
    y += (b-a)//2
print('Yes' if y >= x and n >= y-x else 'No')

Submission status: Wrong Answer

Solution code:
n = int(input())
an = [int(i) for i in input().split()]
bn = [int(i) for i in input().split()]
suma = sum(an)
sumb = sum(bn)
if suma > sumb:
  print('No')
elif suma == sumb:
  for i in range(len(an)):
    if an[i] != bn[i]:
      print('No')
      exit()
  print('Yes')
elif n >= sumb - suma:
  cnt = 0
  for i in range(len(an)):
    if an[i] < bn[i]:
      cnt += (bn[i]-an[i])//2
  if n >= cnt:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())

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

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

#print (c)

mi = 0
pl = 0

for i in c:
    if i < 0:
        mi += abs(i) // 2
    else:
        pl += i

if mi // 2 < pl:
    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()))
c = []

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

#print (c)

mi = 0
pl = 0

for i in c:
    if i < 0:
        mi -= i // 2
    else:
        pl += i

if mi < pl:
    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()))
c = []

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

print (c)

mi = 0
pl = 0

for i in c:
    if i < 0:
        mi -= i // 2
    else:
        pl += i

if mi < pl:
    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()))
c = []

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

#print (c)

mi = 0
pl = 0

for i in c:
    if i < 0:
        mi -= i
    else:
        pl += i

if mi // 2 < pl:
    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()))

Abigger=0
Bbigger=0
for i in range(N):
  if A[i]>B[i]:
    Abigger+=A[i]-B[i]
  elif B[i]>A[i]:
    Bbigger+=B[i]-A[i]
    
print(("No","Yes")[Bbigger-Abigger*2>0])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
a_diff = 0
b_diff = 0
for i in range(n):
    if a[i] > b[i]:
        a_diff += a[i] - b[i]
    else:
        b_diff += b[i] - a[i]
if a_diff < b_diff:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
a_diff = 0
b_diff = 0
for i in range(n):
    if a[i] > b[i]:
        a_diff += a[i] - b[i]
    else:
        b_diff += b[i] - a[i]
if a_diff % 2 != b_diff % 2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
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()
cnt=0
for i in range(n):
    if a[i]<b[i]:
        cnt+=(b[i]-a[i])//2
    else:
        cnt-=a[i]-b[i]

if cnt<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.sort()
b.sort()
cnt1=0
cnt2=0
ma=sum(b)-sum(a)
if ma<0:
    print("No")
    exit()

for i in range(n):
    if b[i]<=a[i]:
        cnt1+=a[i]-b[i]
    else:
        if (b[i]-a[i])%2==0:
            cnt2+=(b[i]-a[i]+1)//2
        else:
            cnt2+=(b[i]-a[i]+1)//2
            cnt1+=1
#print(cnt1,cnt2)
if cnt1>ma or cnt2>ma:
    print("No")
else:
    print("Yes" if (ma-cnt2)*2==ma-cnt1 else "No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
cnt1=0
cnt2=0
ma=sum(b)-sum(a)

for i in range(n):
    if b[i]<=a[i]:
        cnt1+=a[i]-b[i]
    else:
        if (b[i]-a[i])%2==0:
            cnt2+=(b[i]-a[i])//2
        else:
            cnt2+=(b[i]-a[i])//2+2
cnt=max(cnt1,cnt2)
if cnt<=ma:
    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(reverse=True)
b.sort(reverse=True)
cnt=0
ma=sum(b)-sum(a)

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

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)

def main():
    n = int(input().strip())
    a = list(map(int, input().strip().split()))
    b = list(map(int, input().strip().split()))
    k = sum(b) - sum(a)
    mink = 0
    for i in range(n):
        if a[i] < b[i]:
            mink += (b[i] - a[i]) // 2
        else:
            mink += a[i] - b[i]
    if mink <= k:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)

def main():
    n = int(input().strip())
    a = list(map(int, input().strip().split()))
    b = list(map(int, input().strip().split()))
    k = sum(b) - sum(a)
    mink = 0
    for i in range(n):
        if a[i] < b[i]:
            mink += (b[i] - a[i] + 1) // 2
        else:
            mink += a[i] - b[i]
    if mink <= k:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()