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 Rust (1.15.1) (judge verdict: Wrong Answer)

#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: u32 = read();
    let mut As: Vec<u32> = vec![];
    let mut Bs: Vec<u32> = vec![];
    for _ in 0..N {
        As.push(read());
    }
    for _ in 0..N {
        Bs.push(read());
    }
    let mut del_index = None;
    let mut min = std::u32::MAX;
    for ((ai, av), (_bi, bv)) in As.iter().enumerate().zip(Bs.iter().enumerate()) {
        if bv >= av && *bv < min {
            del_index = Some(ai);
            min = *bv;
        }
    }
    if del_index == None {
        println!("No");
        return;
    }
    let del_index = del_index.unwrap();
    As.remove(del_index);
    Bs.remove(del_index);
    As.sort();
    Bs.sort();
    for (a, b) in As.iter().zip(Bs.iter()) {
        if b < a {
            println!("No");
            return;
        }
    }
    println!("Yes");
}