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

Solution in Go (1.6) (judge verdict: Runtime Error)

package main

import "fmt"

func main() {
	var N int
	var BufA string
	var BufB string
	var A []string
	var B []string
	var ans string = "Yes"

	fmt.Scan(&N)
	fmt.Scan(&BufA)
	fmt.Scan(&BufB)

	for _, v := range BufA {
		A = append(A, string(v))
	}
	for _, v := range BufB {
		B = append(B, string(v))
	}
	QuickSort(A)
	QuickSort(B)
	for i := 0; i < len(A); i++ {
		if A[i] <= B[i] {
			continue
		} else {
			ans = "No"
			break
		}
	}
	fmt.Println(ans)
}
func Med3(x, y, z string) string {
	if x < y {
		if y < z {
			return y
		} else if x < z {
			return z
		} else {
			return x
		}
	} else {
		if x < z {
			return x
		} else if y < z {
			return z
		} else {
			return y
		}
	}
}
func QuickSort(a []string) {
	pivot := Med3(a[0], a[len(a)/2], a[len(a)-1])
	left := 0
	right := len(a) - 1
	for {
		// 交換する対象を探す
		for a[left] < pivot {
			left++
		}

		for a[right] > pivot {
			right--
		}

		// 左右からの探索が交差したら終了
		if left >= right {
			break
		}

		// 対象を交換
		a[left], a[right] = a[right], a[left]

		flg := true
		if a[right] == pivot {
			left++
			flg = false
		}
		if a[left] == pivot && flg {
			right--
		}

	}

	a1 := a[:left]
	if len(a1) > 1 {
		QuickSort(a1)
	}

	a2 := a[right+1:]
	if len(a2) > 1 {
		QuickSort(a2)
	}

	cnt := 0
	for _, v := range a1 {
		a[cnt] = v
		cnt++
	}
	a[cnt] = pivot
	cnt++
	for _, v := range a2 {
		a[cnt] = v
		cnt++
	}

}