P26823 [AtCoder] Swaps
提高
题目描述

Problem Description

Given two integer sequences of $ N $ elements each, $ A_1,...,A_N $ and $ B_1,...,B_N $, determine if it is possible to make $A_i \leq B_i$ for all integers $ i $ from 1 to $ N $ by performing the following operation up to $ N-2 $ times (including zero times):

  • Choose distinct integers $ x $ and $ y $ between 1 and $ N $, and swap the values of $ A_x $ and $ A_y $.

Input Format

The input is given from the standard input in the following format:

$ N $ $ A_1 $ $ A_2 $ $ ... $ $ A_N $ $ B_1 $ $ B_2 $ $ ... $ $ B_N $

Output Format

Output Yes if it is possible, otherwise output No.

Sample Input and Output

Sample Input #1

3
1 3 2
1 2 3

Sample Output #1

Yes

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

Notes/Hints

Constraints

  • $2 \leq N \leq 10^5$
  • $1 \leq A_i, B_i \leq 10^9$

Sample Explanation 1

It is sufficient to swap the values of $ A_2 $ and $ A_3 $.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 1 3 2 1 2 3
样例输出
Yes