Problem:


Score : 600 points

Problem Statement

Given are two integer sequences of N elements each: A_1,...,A_N and B_1,...,B_N.
Determine if it is possible to do the following operation at most N-2 times (possibly zero) so that, for every integer i from 1 to N, A_i \leq B_i holds:

Choose two distinct integers x and y between 1 and N (inclusive), and swap the values of A_x and A_y.

Constraints

2 \leq N \leq 10^5

1 \leq A_i,B_i \leq 10^9

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 the objective is achievable, print Yes; if it is not, print No.

Sample Input 1

3
1 3 2
1 2 3

Sample Output 1

Yes

We should swap the values of A_2 and A_3.

Sample Input 2

3
1 2 3
2 2 2

Sample Output 2

No

Sample Input 3

6
3 1 2 6 3 4
2 2 8 3 4 3

Sample Output 3

Yes



Sample input:
3
1 3 2
1 2 3


Sample output:
Yes

Submission status: Wrong Answer

Solution code:

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

if (max(b) < max(a)):
    print ('No')

else :
    count = 0
    ng = 0
    for i in range(len(a)):
        if (a[i] > b[i]):
            for j in range(len(b)):
                if (a[i] <= b[j] and a[j] <= b[i]):
                    a[i],a[j] = a[j],a[i]
                    count = count + 1
                    break
                else :
                    ng = 1
                    print('No')

    #for k in range(len(a)):
    #    if (a[i] > b[i]):
    #        print ('No')
    

    if (n-2 >= count and ng == 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()))
ab=[[a[i],b[i]] for i in range(n)]
#print(ab)
a.sort()
b.sort()


for i in range(n):
    if b[i]<a[i]:
        s="No"
        break
else:
    s="Yes"
    ab.sort(key=lambda x:x[1])
    for i in range(n-1):
        a[-1-i],a[-2-i]=a[-2-i],a[-1-i]

    a2=[]
    for i in range(n):
        a2.append(ab[i][0])

    if a2==a:
        s="No"

    print(s)

    #print(a)
    #print(a2)

Submission status: Wrong Answer

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


def check(lis1, lis2):
  diff = [0 if ai<=bi else 1 for ai,bi in zip(lis1,lis2)]
  tmp = sum(diff)
  lis1 = sorted(lis1)
  lis2 = sorted(lis2)
  diff = [0 if ai<=bi else 1 for ai,bi in zip(lis1,lis2)]
  if sum(diff)==0 and tmp<len(lis1)-1:
    return "Yes"
  else:
    return "No"

diff = [0 if ai<=bi else 1 for ai,bi in zip(a,b)]
tmp = sum(diff)
a_res = [ai for ai,bi in zip(a,b) if ai>bi]
b_res = [bi for ai,bi in zip(a,b) if ai>bi]

print(a_res)
print(b_res)

if check(a_res, b_res)=="Yes":
  print("Yes")
  sys.exit(0)

a = sorted(a)
b = sorted(b)

diff = [0 if ai<=bi else 1 for ai,bi in zip(a,b)]

if sum(diff)==0 and tmp<n-1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
import heapq
n = int(input())
a = list(int(x) for x in input().split())
b = list(int(x) for x in input().split())

ans = True

a_1, b_1 = sorted(a), sorted(b)
for value_a, value_b in zip(a_1, b_1):
    if value_a > value_b:
        ans = False
        break


b_2 = list([i, j] for i, j in zip(b, range(n)))
b_2.sort()
a_2 = []
for k, l in zip(b_2, range(n)):
    heapq.heappush(a_2, [a[k[1]], l])
key = 0
while ans:
    value = heapq.heappop(a_2)
    if key == value[1]:
        break
    if not a_2:
        ans = False
if ans:
    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()))
import heapq
heapq.heapify(A)
heapq.heapify(B)
for i in range(n):
  if heapq.heappop(A) > heapq.heappop(B):
    print('No')
    exit()
print('Yes')

Submission status: Wrong Answer

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

check = [a <= b for a, b in zip(A, B)]

if sum(check) <= 1:
    print('No')
    exit()

A_ = sorted(A)
B_ = sorted(B)

check_ = [a <= b for a, b in zip(A_, B_)]

if len(check_) == sum(check_):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

a = l()
b = l()

aaa = []
bb = []

for i in range(n):
    aaa.append(a[i])
    bb.append([b[i],i,a[i]])

aaa.sort()
bb.sort()
aa = s(aaa)

kkk = {}

count = 0
for i in range(len(aa)):
    kkk[aa[i][0]] = [count,count + aa[i][1] - 1]
    count += aa[i][1]
count = 0
for i in range(n):
    k = bb[i][2]
    if i >= kkk[k][0] and kkk[k][1] <= i:
        count += 0
    else:
        count += 1



if count >= n-2:
    print("No")
else:
    for i in range(n):
        if not aaa[i] <= bb[i][0]:
            print("No")
            exit()
    print("Yes")

Submission status: Wrong Answer

Solution code:
from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math

# 入力 =stdin.readline().rstrip()
# 分割 = stdin.readline().rstrip().split()

'''
条件に合うものを絞り込む
data = [1, 2, 3]
s = [x for x in data if x % 3 == 0]
'''

'''
文字配列を数値に
l_si = ['-10', '0', '100']

l_si_i = [int(s) for s in l_si]
'''

'''
a = [2, 4, 6, 8]
b = [3, 6, 9]

print(list(set(a) | set(b)))  # 和集合
print(list(set(a) & set(b)))  # 積集合
'''

'''
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
count = 0
while len([x for x in A if x % 2 == 0]) == N:
    A = list(map(lambda y: y / 2, A))
    count += 1
print(count)
'''

'''
.append(要素)
.extend(要素)
.insert(場所,要素)
del 配列名[場所]
-1で末尾で末尾から一つ前
'''
'''
間に空白追加
' '.join(lis)
'''
'''
copy.copy(配列名)
'''
'''
sort()50
sorted(reverse=true)
'''
'''
2分探索
bisect.bisect_left(リスト, 要素)
'''
N = int(stdin.readline().rstrip())
_A = stdin.readline().rstrip().split()
_B = stdin.readline().rstrip().split()

A = [int(s) for s in _A]
B = [int(s) for s in _B]
C = copy.copy(A)
A.sort()
B.sort()

tes = True
for n in range(N):
    if (A[n] > B[n]):
        print('No')
        tes = False
        break

if (tes):
    print('Yes')

Submission status: Wrong Answer

Solution code:
import sys

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

for i in range(n):
    if B[i] < A[i]:
        print('No')
        sys.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 = 'Yes'
for i in range(n):
    if A[i] <= B[i]:
        continue
    else:
        ans = 'No'
        break

print(ans)

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()]
sa, sb = sorted(a), sorted(b)
for i in range(n):
    if sa[i] > sb[i]:
        print("No")
        break
else:
    print("Yes")

Submission status: Wrong Answer

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

a = [int(i) for i in a]
b = [int(i) for i in b]

a.sort()
b.sort()

for i in range(n):
    if a[i] <= b[i]:
        continue
    else:
        print('No')
        exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b= list(map(int, input().split()))
d = [b[i]-a[i] for i in range(n)]
l = len(list(filter(lambda x:x<0,d)))
if l >= n - 1:
  ans = 'No'
else:
  a = sorted(a)
  b = sorted(b)
  ans = 'Yes'
  for i in range(len(a)):
    if b[i] - a[i] < 0:
      ans = 'No'
print(ans)

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

answer = "Yes"

for i in range(0,N):
  if A[i] < B[i]:
    answer = "No"

print(answer)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A_mat = np.array(A)
B_mat = np.array(B)
C_mat = B_mat - A_mat
C = C_mat.tolist()
x = 10 ** 10 #初期値
num = 0 #初期値
for i in range(len(C)):
    if 0 <= C[i] < x:
        x = C[i]
        num = i
if x == 10 ** 10:
    print('No')
else:
    A_1 = A_mat.tolist()
    B_1 = B_mat.tolist()
    A_1.pop(num)
    B_1.pop(num)
    
    A_1.sort()
    B_1.sort()
    
    A1_mat = np.array(A_1)
    B1_mat = np.array(B_1)
    
    C1 = B1_mat - A1_mat
    if np.all(C1 >= 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()))


def f():
    A.sort()
    B.sort()

    
    for a, b in zip(A, B):
        if a > b:
            return 'No'
        
    return 'Yes'


print(f())

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

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

AA = np.array(A)
BB = np.array(B)

#確認
sortC = np.array(sorted(B)) - np.array(sorted(A))
outrange = 0
for i in sortC:
  if i < 0:
    outrange += 1
if outrange >0:
  print("No")
  exit()

mainus = BB-AA
negative = 0
for i in mainus:
  if i < 0:
    negative += 1

if math.ceil(negative//2) <= n-2:
  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 max(a) > max(b):
    print('No')
else:
    if min(a) > min(b):
        print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

a = l()
b = l()

aaa = []
bb = []

for i in range(n):
    aaa.append(a[i])
    bb.append([b[i],i,a[i]])

aaa.sort()
bb.sort()
aa = s(aaa)

kkk = {}

count = 0
for i in range(len(aa)):
    kkk[aa[i][0]] = [count,count + aa[i][1] - 1]
    count += aa[i][1]
count = 0
for i in range(n):
    k = bb[i][2]
    if i >= kkk[k][0] and kkk[k][1] <= i:
        count += 0
    else:
        count += 1



if count >= n-1:
    print("No")
else:
    for i in range(n):
        if not aaa[i] <= bb[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()))

A = sorted(A)
B = sorted(B)

print('Yes' if all(a <= b for a, b in zip(A, B)) else 'No')

Submission status: Wrong Answer

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

AA = sorted(A)
BB = sorted(B)

IA = {}
IB = {}
for i in range(N):
    IA[A[i]] = i
    IB[B[i]] = i

for i in range(N):
    if AA[i] > BB[i]:
        print("No")
        break
else:
    i = 0
    j = 0
    k = 0
    X = [0] * N
    Y = [0] * N
    for j in range(N):
        while i < N - 1 and AA[i+1] <= BB[j]:
            i += 1
        X[j] = i
        Y[j] = k
        if i == j: k = i + 1
    
    for i in range(N):
        if IA[AA[Y[i]]] <=  IB[BB[i]] <= IA[AA[X[i]]]:
            print("Yes")
            break
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ab=[[a[i],b[i]] for i in range(n)]
#print(ab)
a.sort()
b.sort()


for i in range(n):
    if b[i]<a[i]:
        s="No"
        break
else:
    s="Yes"

ab.sort(key=lambda x:x[1])
for i in range(n-1):
    a[-1-i],a[-2-i]=a[-2-i],a[-1-i]


a2=[]
for i in range(n):
    a2.append(ab[i][0])

if a2==a:
    s="No"

print(s)

#print(a)
#print(a2)

Submission status: Wrong Answer

Solution code:
u=input()
s=list(map(int,input().split()))
t=list(map(int,input().split()))
a=int(u)
b=0
list=[]
for i in range(a):
  list.append([t[i],s[i]])
list.sort()
c=0
for l in range(a):
  if list[l][1]!=s[l]:
    c+=1
s.sort()
t.sort()
for j in range(a):
  if s[j]>t[j]:
    b+=1
    break
if b>0:
  print('No')
else:
  if c>a-1:
    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(reverse=True)
B.sort(reverse=True)

for i in range(N):
    if not A[i] <= B[i]:
        print("No")
print("Yes")

Submission status: Wrong Answer

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

if max(a) > max(b):
    print('No')
else:
    if min(a) < min(b):
        print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
b_ls = [int(i) for i in sys.stdin.readline().split()]
a_ls, b_ls = zip(*sorted([(a, b) for a, b in zip(a_ls, b_ls)], key=lambda x:x[1]))
a_ls = list(a_ls)
cnt = 0
last = n - 1
flg = True
for i, (a, b) in enumerate(zip(a_ls, b_ls)):
    if b < a:
        last = n - 1
        while b < a_ls[last]:
            last -= 1
            if last <= i:
                flg = False
                break
        tmp = a_ls[i]
        a_ls[i] = a_ls[last]
        a_ls[last] = a_ls[i]
        cnt += 1
        if cnt > n - 2:
            flg = False
            break
    if not flg:
        break
if flg:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
xs = [int(i) for i in input().split()]
ys = [int(i) for i in input().split()]

valid = True

if(valid):
    xs.sort()
    ys.sort()

    for i in range(n):
        if (xs[i]>ys[i]):
            valid = False
            print("No")
            break

if(valid):
    print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
asort = sorted(a)
bsort = sorted(b)
dic = {}
for ai, bi in zip(a, b):
    k = str(ai) + "-" + str(bi)
    dic[k] = 1
f = 1
c = 0
for ai, bi in zip(asort, bsort):
    if ai > bi:
        f= 0
        break
    k = str(ai) + "-" + str(bi)
    if k in dic:
        c += 1
if c and f:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = input()
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
b.sort()
r = "Yes"
for i in range(len(a)):
    if b[i] < a[i]:
        r = "No"
        break
print(r)

Submission status: Wrong Answer

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

A_sort = sorted(A)
B_sort = sorted(B)

for i in range(len(A)):
    if A_sort[i] > B_sort[i]:
        print("No")
        exit()

tmp = 0
swap_cnt = 0
for i in range(len(A)):
    if swap_cnt > N-2 :
        print("No")
        exit()
    for j in range(i, len(A)):
        if A[i] > A[j]:
            tmp = A[i]
            A[i] = A[j]
            A[j] = tmp
            swap_cnt += 1
      
print("Yes" if swap_cnt <= N-2 else "No")

Submission status: Wrong Answer

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

As = sorted(A)
Bs = sorted(B)

ans = "Yes"
for i in range(N):
    if As[i] > Bs[i]:
        ans = "No"
        break
    
cnt = 0
for i in range(N):
    if A[i] > B[i]:
        cnt += 1
        
if cnt > N-2:
    ans = "No"
    
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
alis = list(map(int, input().split()))
blis = list(map(int, input().split()))
alis.sort()
blis.sort()
count = 0
for i in range(n):
    if alis[i] <= blis[i]:
        count += 1
if count == n:
    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()
ans = 'Yes'
for i in range(n):
    if a[i]>b[i]:
        ans = 'No'
        break
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
sys.setrecursionlimit(10**9)
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    A=list(map(int,input().split()))
    B=list(map(int,input().split()))
    Ai=np.argsort(A)
    Bi=np.argsort(B)
    for a_i,b_i in zip(Ai,Bi):
        if A[a_i]>B[b_i]:
            print('No')
            quit()
    d={}
    for i in range(N):
        if A[Bi[i]]==A[Ai[i]]:
            print('Yes')
            quit()
        if B[Bi[i]]==A[Ai[i]]:
            print('Yes')
            quit()
    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.sort()
B.sort()

for i in range(N):
    if not A[i]<=B[i]:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted(list(map(int,input().split())))
b = sorted(list(map(int,input().split())))
ans = 'Yes'
for i in range(n):
    if a[i] > b[i]:
        ans = 'No'
        break
print(ans)

Submission status: Wrong Answer

Solution code:
#                         author:  kagemeka 
#                         created: 2019-11-09 21:20:16(JST)
### modules
## from standard library
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## from external libraries
# import scipy.special   
# import scipy.misc      
# import numpy as np 

def main():
    n = int(sys.stdin.readline().rstrip())
    a = [int(x) for x in sys.stdin.readline().split()]
    b = [int(x) for x in sys.stdin.readline().split()]

    a.sort()
    b.sort()
    for i in range(n):
        if a[i] > b[i]:
            print('No')
            exit()
    print('Yes')


if __name__ == "__main__":
    # execute only if run as a script
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
yes, no = "Yes", "No"
n = int(input())
a = np.array(list(map(int, input().split())))
b = np.array(list(map(int, input().split())))
sb = np.sort(b)
sa = np.sort(a)
sbi = np.argsort(b)
if np.any(sb < sa):
    print(no)
    exit(0)
if np.any(sb[:-1] >= sa[1:]):
    print(yes)
    exit(0)

count = 1
i = 0
while True:
    j = sbi[i]
    if j == 0:
        break
    i = j
    count += 1
if count == n:
    print(no)
else:
    print(yes)

Submission status: Wrong Answer

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

a = l()
b = l()

aaa = []
bb = []

for i in range(n):
    aaa.append(a[i])
    bb.append([b[i],a[i],i])

aaa.sort()
bb.sort()
aa = s(aaa)

kkk = {}

count = 0
for i in range(len(aa)):
    kkk[aa[i][0]] = [count,count + aa[i][1] - 1]
    count += aa[i][1]
count = 0
for i in range(n):
    k = bb[i][1]
    if i >= kkk[k][0] and kkk[k][1] <= i:
        count += 0
    else:
        count += 1



if count >= n-1:
    print("No")
else:
    for i in range(n):
        if not aaa[i] <= bb[i][0]:
            print("No")
            exit()
    print("Yes")

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A_mat = np.array(A)
B_mat = np.array(B)
C_mat = B_mat - A_mat
C = C_mat.tolist()
x = 10 ** 10
num = 0
for i in range(len(C)):
    if 0 <= C[i] < x:
        x = C[i]
        num = i
A_1 = A_mat.tolist()
B_1 = B_mat.tolist()
A_1.pop(num)
B_1.pop(num)

A_1.sort()
B_1.sort()

A1_mat = np.array(A_1)
B1_mat = np.array(B_1)

C1 = B1_mat - A1_mat
if np.all(C1 >= 0):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
xs = [int(i) for i in input().split()]
ys = [int(i) for i in input().split()]

valid = True
c = 0
for i in range(n):
    if(xs[i]<=ys[i]):
        c += 1
    if(c>=2):
        break
else:
    valid = False
    print("No")

if(valid):
    xs.sort()
    ys.sort()

    for i in range(n):
        if (xs[i]>ys[i]):
            valid = False
            print("No")
            break

if(valid):
    print("Yes")

Submission status: Wrong Answer

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

c1 = 0
for i in range(N):
  if A[i] <= B[i]:
    c1 += 1
A.sort()
B.sort()
c2 = 0
for i in range(N):
  if A[i] <= B[i]:
    c2 += 1
if c1 >= 1 and c2 == N:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# coding: utf-8

from collections import Counter
def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    la = rli()
    lb = rli()
    ll = []
    pb = []
    for i in range(n):
        ll.append([la[i], lb[i]])
    ll.sort()
    for i in range(n):
        pb.append([ll[i][1], i])
    pb.sort()
    pc = [0 for _ in range(n)]
    for i in range(n):
        pc[pb[i][1]] = i
    # print(pb)
    # print(pc)

    la.sort()
    lb.sort()
    for i in range(n):
        if la[i] > lb[i]:
            print("No")
            return

    cnt = 0
    # print(ll)
    for i in range(n):
        j = pc[i]
        if i == j:
            continue
        if ll[i][0] != ll[j][0] and ll[i][1] != ll[j][1]:
            cnt += 1
        ll[i][1], ll[j][1] = ll[j][1], ll[i][1]
        pc[i], pc[j] = pc[j], pc[i]
        # print(i, j, ll[i], ll[j])
    # print(ll)
    if cnt <= n-2:
        print("Yes")
    else:
        print("No")
    

    # print('Yes')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())

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

for j in range(n):
    if a[j] > b[j]:
        cnt +=1
#print(cnt)
a.sort()
b.sort()

for i in range(n):
    if a[i] <= b[i]:
        if i == n - 1:
            if cnt > n-2:
                print('No')
                sys.exit()
            elif cnt > n - 3:
                print('No')
                sys.exit()
            else:
                print('Yes')
                sys.exit()
    else:
        print('No')
        sys.exit()

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.sort()
b.sort()
f=0
for i in range(n):
    if a[i]>b[i]:
        f+=1
        if f>1:
            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()))

n_A=sorted(A)
n_B=sorted(B)
d=[]
for i in range(N):
    e=n_B[i]-n_A[i]
    if e<0:
        d.append(e)
        
if sum(d)>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())) 

if max(a) > max(b):
    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(reverse=True)
B.sort(reverse=True)

if A[0] <= B[0]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

# B が小さいほど制約が大きいのでBが小さいものからみる
C = sorted(zip(A, B), key=lambda x: x[1])
A, B = map(list, zip(*C))

ans = 0
for i in range(N):
    if ans > N - 2:
        print("No")
        exit()
    if (A[i] > B[i]):
        if [k for k in A[i + 1:] if k <= B[i]]:
            j = A[i + 1:].index(max([k for k in A[i + 1:] if k <= B[i]]))
            A[i], A[j] = A[j], A[i]
            ans += 1
        else:
            print("No")
            exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
ar = list()
for n in range(N):
    ar.append([A[n],B[n]])
ar = sorted(ar, key=lambda x:x[1])
A = [x[0] for x in ar]
B = [x[1] for x in ar]
calc = max(A) <= max(B)
if not calc:
    print("No")
else:
    if N >= 2:
        count = 0
        meet = 0
        not_meet = 0
        _A = list()
        _B = list()
        for n in range(N):
            if A[n] <= B[n]:
                meet += 1
            else:
                _A.append(A[n])
                _B.append(B[n])
                not_meet += 1
        if meet >= 2:
            if max(_A) <= max(_B):
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    if N == 1:
        print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
import math as mp
from itertools import permutations

def l_i():
    arr = [int(a) for a in input().strip().split(' ')]
    return arr
c=0
n=int(input())
ar=sorted(l_i())
br=sorted(l_i())
for i in range(n):
    if(ar[i]<=br[i]):
        c=c+1
    else:
        print('No')
        break
if(c==n):
    print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
# diffの少なくとも一つがプラスand sortしてすべてがB >= A
diff = [b - a for a, b in zip(A, B)]

sA = sorted(A)
sB = sorted(B)

sdiff = [b - a for a, b in zip(sA, sB)]

if any([i >= 0 for i in diff]) and all([i >= 0 for i in sdiff]):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=sorted(a)
d=sorted(b)
f=False
t=0
for i in range(n):
  if c[i]>d[i]:
    f=True
  if a[i]<=b[i]:
    t+=1
if f:
  print('No')
else:
  if t<2:
    print('No')
  else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
import bisect
n=int(input())
la=list(map(int,input().split()))
lb=list(map(int,input().split()))
las=sorted(la)
lab=sorted(lb)
for i in range(n):
    if las[i]>lab[i]:
        print("No")
        exit()
sa=set(la)
sb=set(lb)
if len(sa)!=n or len(sb)!=n:
    print("Yes")
    exit()
lc=sorted([[lb[i],la[i]] for i in range(n)])
a=[0]*n
for num,i in enumerate(lc):
    a[num]=bisect.bisect_left(las,i[1])
used = [ False ] * n
cnt = 0
for i in range(n):
    j = i
    used[j] = True
    while a[j] != j:
        j = a[j]
        if used[j]:
            break
        used[j] = True
        cnt += 1
if cnt<n-1:
    print("Yes")
else:print("No")

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())

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

for j in range(n):
    if a[j] > b[j]:
        cnt +=1
#print(cnt)
a.sort()
b.sort()

for i in range(n):
    if a[i] <= b[i]:
        if i == n - 1:
            if cnt > n-2:
                print('No')
                sys.exit()
            elif cnt > n - 1:
                print('No')
                sys.exit()
            else:
                print('Yes')
                sys.exit()
    else:
        print('No')
        sys.exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
alis = list(map(int, input().split()))
blis = list(map(int, input().split()))
alis.sort()
blis.sort()
count = 0
for i in range(n):
    if alis[i] >= blis[i]:
        count += 1
if count == n:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A_mat = np.array(A)
B_mat = np.array(B)
C_mat = B_mat - A_mat
C = C_mat.tolist()
x = 10 ** 8 #初期値
num = 0 #初期値
for i in range(len(C)):
    if 0 <= C[i] < x:
        x = C[i]
        num = i
A_1 = A_mat.tolist()
B_1 = B_mat.tolist()
A_1.pop(num)
B_1.pop(num)

A_1.sort()
B_1.sort()

A1_mat = np.array(A_1)
B1_mat = np.array(B_1)

C1 = B1_mat - A1_mat
if np.all(C1 >= 0):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import math
YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, A: "List[int]", B: "List[int]"):
    if max(B)<max(A):
        print(NO)
        return
    
    ## 完成形を作る
    B_tuple = []
    A_tuple = []
    for i in range(N):
        B_tuple.append((B[i],i))
        A_tuple.append((A[i],i))
    
    A_tuple.sort(key=lambda x: x[0])
    B_tuple.sort(key=lambda x: x[0])
    dif = 0
    for i in range(N):
        dif += abs(A_tuple[i][1]-B_tuple[i][1])
    
    if math.ceil(dif/2) <= N-2:
        print(YES)
    else:
        print(NO)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A, B)

if __name__ == '__main__':
    main()