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(" ")))
z=sorted(zip(a,b),key=lambda x:x[1])
a=list(map(lambda x:x[0],z))
b=list(map(lambda x:x[1],z))

spCount=0
for i in range(N):
    if a[i]<=b[i]:
        spCount+=1
a=sorted(a)
winFlag=True
for i in range(N):
    if a[i]>b[i]:
        winFlag=False
        break
if winFlag:
    if spCount>2:
        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()))

aa=sorted(a)
bb=sorted(b)
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()))

for a, b in zip(sorted(A), sorted(B)):
    if a > b:
        print('No')
        exit()

print('Yes')

Submission status: Wrong Answer

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

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


if max(A) > max(B):
    print("No")
    exit(0)

B.sort()
A.sort()

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

Submission status: Wrong Answer

Solution code:
N = int(input())
D = sorted(list(map(int,input().split())))
MOD = 998244353

ans = 1
count = {}
for i in range(N):
  if i < D[i] or (i > 0 and D[i] == 0):
    print(0)
    exit()
  else:
    if D[i] in count:
      count[D[i]] += 1
    else:
      count[D[i]] = 1
    if D[i] > 0:
      ans *= count[D[i]-1]
      ans %= MOD
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()]

flag = 0
for i in range(N):
    if A[i]<=B[i]:
        flag = 1
        break

if flag == 1:
    A_s =sorted(A)
    B_s =sorted(B)
    for i in range(N):
        if A_s[i]>B_s[i]:
            flag = 0
            break
        
if flag == 1:
    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()]
X=sorted([(A[i],B[i]) for i in range(N)],key=lambda x:x[1])
A=[X[i][0] for i in range(N)]
B=[X[i][1] for i in range(N)]
C=sorted([(A[i],i) for i in range(N)],key=lambda x:x[0])
for i in range(N):
    if C[i][0]>B[i]:
        print("No")
        exit()
if len(set(A))<N:
    print("Yes")
    exit()
Y=[0 for i in range(N)]
j=0
for i in range(N):
    Y[j]=1
    j=C[j][1]
if sum(Y)==N:
    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()))

Asorted = sorted(A)
Bsorted = sorted(B)

Amin = min(A)
Bmax = max(B)

isCan = True

if Amin > Bmax:
    isCan = False

for i in range(N):
    if Asorted[i] > Bsorted[i]:
        isCan = False

if isCan:
    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()
    la.sort()
    lb.sort()
    for i in range(n):
        if la[i] > lb[i]:
            print("No")
            return
    print('Yes')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def is_possible_build_swap(n, a, b):
    i = 0
    while i < n:
        if a[i] <= b[i]:
            k = -1
            mn = a[i]
            for j in range(i+1, n):
                if mn < a[j] <= b[i]:
                    mn = a[j]
                    k = j
            if k != -1:
                a[i], a[k] = a[k], a[i]
            i += 1
        else:
            mn = 0
            k = -1
            for j in range(i+1, n):
                if mn <= a[j] <= b[i]:
                    mn = a[j]
                    k = j
            if k == -1:
                return False
            else:
                a[i], a[k] = a[k], a[i]
                i += 1
    return True

def solve():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    print("Yes" if is_possible_build_swap(n, a, b) else "No")


if __name__ == "__main__":
    solve()

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:
import sys

N = int(sys.stdin.readline())

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

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

count = 0

for i in range(N):
    if A[i] > B[i]:
        count += 1
if count >= N:
    ans = "No"
    print("a")
    print(ans)
    sys.exit()

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

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

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-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()))
A.sort()
B.sort()
ans = 'Yes'
for i in range(N):
    if A[i] > B[i]:
        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()
flag=False
for i in range(N):
  if A[i]>B[i]:
    flag=True
if flag==True:
  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()))

cnt = 0
for a, b in zip(A, B):
    if a > b:
        cnt += 1

for a, b in zip(sorted(A), sorted(B)):
    if a > b:
        print('No')
        exit()

if cnt <= N - 2:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
lista = list(map(int,input().split()))
listb = list(map(int,input().split()))

count = 0

for i in range(n):
    if lista[i] <= listb[i]:
        count += 1

if count < n-(n-2):
    print("No")
    exit()

lista.sort()
listb.sort()
 
for i in range(n):
    if lista[i] > listb[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()))

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

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 numpy as np

N = int(input())
A = np.sort(np.array(list(map(int, input().split()))))
B = np.sort(np.array(list(map(int, input().split()))))

if np.all(A <= B):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = input().split()
B = input().split()
preANS = 0

for i in range(N):
    A[i] = int(A[i])

for i in range(N):
    B[i] = int(B[i])

for i in range(N):
    if A[i] > B[i]:
        for j in range(N):
            if A[j] < B[i]:
                A[i], A[j] = A[j], A[i]
                preANS += 1

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

a.sort()
b.sort()

flag = False
for i in range(n):
    if a[i] <= b[i]:
        pass
    else:
        flag = True

if flag:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

a.sort()
b.sort()

for i in range(n):
    if a[i]-b[i]<0:
        print("No")
        sys.exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
import sys

def main():
    sys.stdin.readline()
    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 a, b in zip(A, B):
        if a > b:
            print('No')
            return
    print('Yes')

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

if(min(a)>min(b)):
  print("No")
else:
  for i in range(n):
    if(a[i] <= b[i]):
      if(i==n-1):
        print("Yes")
        break
      continue
    else:
      print("No")
      break

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if n == 2:
    if a[0] <= b[0] and a[1] <= b[1]:
        print('Yes')
    else:
        print('No')
    exit()
cnt = sum([1 if a[i] > b[i] else 0 for i in range(n)])
if cnt == n - 1:
    print('No')
    exit()
else:
    a.sort()
    b.sort()
    for i in range(n):
        if a[i] > b[i]:
            print('No')
            exit()
    print('Yes')

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
A.sort()
B.sort()
for i in range(N):
    if A[i]>B[i]:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

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

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

a.sort()
b.sort()

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

Submission status: Wrong Answer

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


A_copy_sorted = sorted(deepcopy(A))
B_copy_sorted = sorted(deepcopy(B))
for a, b in zip(A_copy_sorted, B_copy_sorted):
    if a > b:
        print('No')
        exit()


print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A.sort()
B.sort()
for i in range(N):
  if A[i] > B[i]:
    print('No')
    exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A_ = sorted(A)
B_ = sorted(B)
f = True
for a, b in zip(A_,B_):
    if a > b:
        f = False
if f:
    c = 0
    for a, b in zip(A,B):
        if a > b:
            c+=1
    if c <= N-2:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
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()]

    S_A = sorted(A)
    S_B = sorted(B)

    for i, a in enumerate(S_A):
        if S_A[i] > S_B[i]:
            print("No")
            exit()

    print("Yes")


if __name__ == '__main__':
    main()

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()))
        
#print(a)
#print(b)

plist = []

for i in range(len(a)):
    if(a[i] == b[i]):
        plist.append(i)
        
for i in range(len(plist)-1,-1,-1):
    x = plist[i]
    a.pop(x)
    b.pop(x)
    
a.sort()
b.sort()

an = np.array(a)
bn = np.array(b)

#print(a)
#print(b)

x = (an >= bn)
if(sum(x > 0)):
    ans = "Yes"
else:
    ans = "No"
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n = int(input())
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))
a = []
b = []
for i in range(0, n):
    if aa[i] != bb[i]:
        a.append(aa[i])
        b.append(bb[i])
a.sort()
b.sort()
flag = 1
for i in range(0, len(a)):
    if a[i] > b[i]:
        flag = 0
        break
if flag == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    n = int(input())
    aa = list(map(int, input().split()))
    bb = list(map(int, input().split()))
    aa.sort()
    bb.sort()
    for a, b in zip(aa, bb):
        if a > b:
            print("No")
            exit()
    print("Yes")

main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math
import collections


N, = map(int, sys.stdin.readline().rstrip().split(" "))
As = list(map(int, sys.stdin.readline().rstrip().split(" ")))
Bs = list(map(int, sys.stdin.readline().rstrip().split(" ")))
As.sort()
Bs.sort()

for A, B in zip(As, Bs):
    if A > B:
        print("No")
        break
else:
    print("Yes")
exit(0)

Submission status: Wrong Answer

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

alis.sort()
blis.sort()
def ab (alis,blis):
    for i in range(n):
        if alis[i] > blis[i]:
            return print('No')
    return print('Yes')
ab(alis,blis)

Submission status: Wrong Answer

Solution code:
N=int(input())

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

for i in range(N):
    if a[i]==b[i]:
        avCount+=1
z=zip(sorted(a),sorted(b))
winFlag=True
for it in z:
    if it[0]>it[1]:
        print("No")
        winFlag=False
        break
if winFlag:
    if avCount>0:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

	flag = False
	for a, b in zip(A, B):
		if a<=b:
			flag = True
			break
	if flag:
		k = sum([a>b for a, b in zip(sorted(A), sorted(B))])
		if k == 0:
			print("Yes")
		else:
			print("No")
	else:
		print("No")

if __name__ == "__main__":
	main()

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

flag = False

for i in range(N):
    if(B[i] - A[i] >= 0):
        flag = True
        break


A.sort()
B.sort()
for i in range(N):
    if(B[i] - A[i] < 0):
        flag = False
        break

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

sorted_A = sorted(A)
sorted_B = sorted(B)

for i in range(N):
    if sorted_A[i] > sorted_B[i]:
        print("No")
        exit(0)
        
print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A.sort()
B.sort()
for a, b in zip(A, B):
    if a > b:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
cnt=0
A.sort()
B.sort()
for i in range(N):
  if B[i]-A[i]<0:
    cnt=cnt+1
if cnt>=N-2:
  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()

result = "Yes"
for i in range(len(A)):
    if A[i] > B[i]:
        result = "No"
        break
    
print(result)

Submission status: Wrong Answer

Solution code:
import bisect

#mod = 1000000007
mod = 998244353

def main():
    n = int(input())
    a = [x for x in map(int,input().split())]
    b = [x for x in map(int,input().split())]
    cnt = 0
    for i in range(n):
        if a[i]>b[i]:
            cnt += 1
    if cnt>n-2:
        print("No")
        return
    a.sort()
    b.sort()
    for i in range(n):
        if a[i]>b[i]:
            print("No")
            return
    print("Yes")
    return


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

sub = [b[i] - a[i] for i in range(n)]

if -1 in sub:
    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()))

a1 = sorted(a)
b1 = sorted(b)

ans = 'Yes'
for i in range(n):
    if a1[i] > b1[i]:
        ans = 'No'
        break

if ans == 'Yes':
    cnt = 0
    for i in range(n):
        if a[i] > b[i]:
            cnt += 1

    if cnt >= n-1:
        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 = sorted(A)
B_sort = sorted(B)

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

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


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

    A = sorted(A)
    B = sorted(B)
    
    for i in range(N):
        if A[i] > B[i]:
            print('No')
            sys.exit()
    print('Yes')


main()

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
AA=sorted(A)
BB=sorted(B)
count_int=0
count_sort=0
for i in range(N):
    if A[i]>B[i]:
        count_int+=1
    if AA[i]>BB[i]:
        count_sort+=1

if count_int>N-2 or count_sort>0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]*n
b=[]*n
a=list(map(int,input().split(" ")))
b=list(map(int,input().split(" ")))
a.sort()
b.sort()
ans=True
for i in range(n):
    if a[i]>b[i]: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()))
a.sort()
b.sort()
for i in range(n):
    if a[i] > b[i]:
        print('No')
        break
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
u=input()
s=list(map(int,input().split()))
t=list(map(int,input().split()))
s.sort()
t.sort()
a=int(u)
b=0
for i in range(a):
  if s[i]>t[i]:
    b+=1
    break
if b>0:
  print('No')
else:
  print('Yes')

Submission status: Wrong Answer

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

a.sort()
b.sort()

for i in range(n):
    if a[i] > b[i]:
        print("No")
        sys.exit(0)
    
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)
ab=[b[i]-a[i] for i in range(n)]
m=min(ab)
print('Yes' if m>=0 else 'No')

Submission status: Wrong Answer

Solution code:
input()
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
for i in range(len(A)):
    if A[i]>B[i]:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

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

A.sort()
B.sort()

for i in range(N):
    if A[i] > B[i]:
        print('No')
        exit()
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()]
ct = 0
for i in range(n):
    if a[i]>b[i]:
        ct += 1
a.sort()
b.sort()
good = True
for i in range(n):
    if a[i]>b[i]:
        good = False
ct //= 2
if ct < n-2 and good:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
input()
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
for i in range(len(A)):
    if A[i]>B[i]:
        print("No",A[i],B[i])
        exit()
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()]

flag = False

for i in range(N):
    if(B[i] - A[i] > 0):
        flag = True
        break


A.sort()
B.sort()
for i in range(N):
    if(B[i] - A[i] < 0):
        flag = False
        break

if(flag):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())

a = sorted([i for i in input().split()])
b = sorted([i for i in input().split()])

flg = 0
for i in range(n):
    if a[i]>b[i]:
        flg = 1
        break
    else:
        pass
print('Yes' if flg==0 else 'No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = sorted(a)
d = sorted(b)
cnt = True
for i in range(n):
  if c[i]>d[i]:
    cnt = False
print("No" if c==c[::-1] else "Yes")

Submission status: Wrong Answer

Solution code:
from sys import stdin
import fractions

n = int(stdin.readline().rstrip())
la = list(map(int,stdin.readline().rstrip().split()))
lb = list(map(int,stdin.readline().rstrip().split()))


la.sort()
lb.sort()

for i in range(n):
    if la[i] > lb[i]:
        print("No")
        exit()
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()]

flag = True

for i in range(N):
    if(B[i] - A[i] < 0):
        flag = False
        break

A.sort()
B.sort()
for i in range(N):
    if(B[i] - A[i] < 0):
        flag = False
        break

if(flag):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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


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

    for i in range(N):
        if A[i] > B[i]:
            print('No')
            exit()

    print('Yes')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
A = LI()
B = LI()

A.sort()
B.sort()

ans = "Yes"
for i in range(N):
    if A[i] <= B[i]:
        pass
    else:
        ans = "No"
        break
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
lista = list(map(int,input().split()))
listb = list(map(int,input().split()))

lista.sort()
listb.sort()

for i in range(n):
    if lista[i] > listb[i]:
        print("No")
        exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A.sort()
B.sort()
for x, y in zip(A, B):
    if x > y:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

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

cnt = 0
for a, b in zip(A, B):
    if a > b:
        cnt += 1

for a, b in zip(sorted(A), sorted(B)):
    if a > b:
        print('No')
        exit()

if (cnt // 2) <= N - 2:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

check = 0

for i in range(N):
  if A[i] <= B[i]:
    check += 1
    
if check == 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()
k = 0
for i in range(N):
    if A[i] <= B[i]:
        continue
    else:
        k += 1
        break
if k == 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()))

cnt = 0
for a, b in zip(A, B):
    if a > b:
        cnt += 1

for a, b in zip(sorted(A), sorted(B)):
    if a > b:
        print('No')
        exit()

if -(-cnt // 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()))

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

ans = 'Yes'
for i in range(n):
    if a[i] > b[i]:
        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()]
a.sort()
b.sort()
good = True
ct = 0
for i in range(n):
    if a[i]>b[i]:
        ct += 1
if ct < 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()))

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

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

if sum(diff)>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()
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 = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

A.sort()
B.sort()
flag = True
for i in range(N):
    if(B[i] - A[i] < 0):
        flag = False
        break

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

ans="Yes"

for i in range(0,n):
    if a[i] > b[i]:
        ans = "No"

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()]
a.sort()
b.sort()
good = True
for i in range(n):
    if a[i]>b[i]:
        good = False
if good:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[int(s) for s in input().split()]
B=[int(s) for s in input().split()]
A.sort()
B.sort()
for i in range(N-1):
  if B[i]>=A[i+1]:
    print("Yes")
    break
else:
  print("No")

Submission status: Time Limit Exceeded

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

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = sorted(zip(B, A))
B, A = zip(*C)
D = sorted((a, i) for i, a in enumerate(A))
E, indices = zip(*D)
for e, b in zip(E, B):
  if e > b:
    print("No")
    exit()
S = set()
now = 0
while len(S) < n-1:
  S.add(now)
  if indices[now] in S:
    print("Yes")
    exit()
  noe = indices[now]
for i in range(n):
  if E[i+1] <= B[i]:
    print("Yes")
    exit()
print("No")

Submission status: Time Limit Exceeded

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

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = sorted(zip(B, A))
B, A = zip(*C)
D = sorted((a, i) for i, a in enumerate(A))
E, indices = zip(*D)
for e, b in zip(E, B):
  if e > b:
    print("No")
    exit()
S = set()
now = 0
while len(S) < n-1:
  S.add(now)
  if indices[now] in S:
    print("Yes")
    exit()
for i in range(n):
  if E[i+1] <= B[i]:
    print("Yes")
    exit()
print("No")

Submission status: Time Limit Exceeded

Solution code:
from bisect import bisect_left
import sys
input = sys.stdin.readline
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)]
ab.sort(key=lambda x:x[1])
a.sort()
b.sort()
for i in range(n):
    if a[i]>b[i]:
        print("No")
        exit()
for i in range(n-1):
    if ab[0][0]>ab[0][1]:
        s = bisect_left(b,ab[0][0])
        if s<len(ab):
            ab[0][0]=ab[s][0]
            ab.pop(s)
            b.pop(s)
        else:
            print("No")
            exit()
    else:
        print("Yes")
        exit()
#print(ans)
print("No")

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import sys
input = sys.stdin.readline
n = int(input())
a = np.array(list(map(int, input().split())))
b = np.array(list(map(int, input().split())))
ab=np.array([np.array([a[i],b[i]]) for i in range(n)])
ab=ab[np.argsort(ab[:,1])]
a.sort()
b.sort()
for i in range(n):
    if a[i]>b[i]:
        print("No")
        exit()
for i in range(n-1):
    if ab[0,0]>ab[0,1]:
        s = np.searchsorted(b,ab[0,0])
        if s<len(ab):
            ab[0,0]=ab[s,0]
            np.delete(ab,s,0)
            np.delete(a,s)
        else:
            print("No")
            exit()
    else:
        print("Yes")
        exit()
#print(ans)
print("No")

Submission status: Time Limit Exceeded

Solution code:
import bisect
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)]
ab.sort(key=lambda x:x[1])
a.sort()
b.sort()
k=0
ans=True
for i in range(n):
    if a[i]>b[i]:
        ans=False
for i in range(n-1):
    if ab[0][0]>ab[0][1]:
        s = bisect.bisect_left(b,ab[0][0])
        if s<len(ab):
            ab[0][0]=ab[s][0]
            ab.pop(s)
            b.pop(s)
        else:
            ans=False
            break
    else:
        break
    k+=1
#print(ans)
if ans and k<n-1:
    print("Yes")
else:
    print("No")