using System; public class Program { public static void Main(string[] args) { Console.ReadLine(); // n string[] s = Console.ReadLine().Split(' '); string[] p = Console.ReadLine().Split(' '); int[] score = new int[101]; // 100人 (score[0]はK君) int max = 0; for (int i = 0; i < s.Length; i++) { int index = int.Parse(p[i]); score[index] += int.Parse(s[i]); if (index != 0 && score[index] > max) { max = score[index]; } } if (score[0] >= max) { Console.WriteLine("YES"); } else { Console.WriteLine("NO"); } } }