using System; using System.Collections.Generic; using System.Linq; public class P0216 { public static void Main() { var n = int.Parse(Console.ReadLine().Trim()); var a = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToList(); var b = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToList(); var dict = new Dictionary(); foreach(var pair in a.Zip(b, (i, j) => new { left = i, right = j })) { dict[pair.right] = dict.GetValueOrDefault(pair.right) + pair.left; } if(dict.GetValueOrDefault(0) >= dict.Values.Max()) { Console.WriteLine("YES"); } else { Console.WriteLine("NO"); } } }