fn main() { let stdin = std::io::read_to_string(std::io::stdin()).unwrap(); let mut stdin = stdin.split_ascii_whitespace(); let n: usize = stdin.next().unwrap().parse().unwrap(); let a: Vec = (0..n) .map(|_| stdin.next().unwrap().parse().unwrap()) .collect(); let b: Vec = (0..n) .map(|_| stdin.next().unwrap().parse().unwrap()) .collect(); println!("{}", output(solve(a, b))); } fn solve(a: Vec, b: Vec) -> bool { let mut points_of = [0; 101]; a.into_iter() .zip(b) .for_each(|(a, b)| points_of[b as usize] += a as u16); points_of[0] >= points_of.into_iter().max().unwrap() } fn output(ans: bool) -> &'static str { match ans { true => "YES", false => "NO", } }