using System; using System.Linq; class Program { static void Main() { int n = int.Parse(Console.ReadLine()); int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray(); int[] b = Console.ReadLine().Split().Select(int.Parse).ToArray(); int score = 0; int sum = 0; for (int i = 0; i < n; i++) { if (b[i] == 0) score += a[i]; } for (int i = 1; i <= 100; i++) { for (int j = 0; j < n; j++) { if (b[j] == i) sum += a[j]; } if (sum > score) { Console.WriteLine("NO"); return; } sum = 0; } Console.WriteLine("YES"); } }