using System.Linq; using System; public class Hello { public static void Main() { var n = int.Parse(Console.ReadLine().Trim()); string[] line = Console.ReadLine().Trim().Split(' '); var a = Array.ConvertAll(line, int.Parse); line = Console.ReadLine().Trim().Split(' '); var b = Array.ConvertAll(line, int.Parse); var c = new int[101]; var ns = 0; for (int i = 0; i < n; i++) if (b[i] == 0) ns += a[i]; else c[b[i]] += a[i]; Console.WriteLine(ns >= c.Max() ? "YES" : "NO"); } }